Skip to content
Snippets Groups Projects
Commit 7905de68 authored by ErikHommel's avatar ErikHommel :homes:
Browse files

fix merge conflict in changelog

parents 09d3d305 d46f030d
No related branches found
No related tags found
No related merge requests found
Version 1.7 (not yet released)
===========
* fixed notice in FormProcessor->invokeFormProcessor
* Fixed #9 Error in the default value
* Fixed #11 Errors in DateType validation
Version 1.6
===========
......
......@@ -227,7 +227,7 @@
// Set default value
if (!isset($params[$input['name']]) && isset($input['default_value']) && $input['default_value'] != '') {
$params[$input['name']] = $input['type']->getDefaultValue($input['default_value']);
$params[$input['name']] = $inputType->getDefaultValue($input['default_value']);
}
if ($input['is_required'] && !isset($params[$input['name']])) {
......
......@@ -4,29 +4,29 @@
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
namespace Civi\FormProcessor\Type;
use \Civi\FormProcessor\Type\GenericType;
use \Civi\FormProcessor\Config\Specification;
use \Civi\FormProcessor\Config\SpecificationBag;
use \CRM_FormProcessor_ExtensionUtil as E;
class DateType extends GenericType {
public function __construct($label) {
parent::__construct('Date', $label);
$this->default_value_description = 'If you want to provide a default date set it here. See <a href="https://secure.php.net/manual/en/datetime.formats.php">Date and Time Formats on php.net</a> for possible formats';
}
/**
* Get the configuration specification.
*
* The configuration is
*
* The configuration is
* format: a string containing the input format.
* see for valid formats http://nl1.php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters
*
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
......@@ -74,7 +74,8 @@
*/
public function normalizeValue($value) {
if ($value) {
$date = new \DateTime($value);
// transform date format to avoid DateTime issues
$date = \DateTime::createFromFormat($this->configuration->get('format'), (string) $value);
if ($this->configuration->get('include_time')) {
return $date->format('YmdHis');
}
......@@ -97,7 +98,7 @@
}
return $value;
}
/**
* Validate the value
*/
......@@ -105,15 +106,11 @@
if (!$this->validateConfiguration()) {
return false;
}
if (!is_string($value))
{
return false;
}
$date = \DateTime::createFromFormat($this->configuration->get('format'), $value);
$date = \DateTime::createFromFormat($this->configuration->get('format'), (string) $value);
if (!$date) {
return false;
}
return true;
}
}
\ No newline at end of file
}
site_name: Form Processor
repo_url: https://lab.civicrm.org/extensions/form-processor
theme: material
theme:
name: material
pages:
nav:
- Introduction: index.md
- Requirements: requirements.md
- Basic Concept: basic-concept.md
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment