diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cbd780f16a92044c60a016f395e03ed1f7059b9..a95d46e4c72cfaddb8ccdeb29f19537a7ccbb9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ 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 =========== diff --git a/Civi/FormProcessor/API/FormProcessor.php b/Civi/FormProcessor/API/FormProcessor.php index f57b2ad894eb91d53b927d7a870efaefa7da3796..f8fcbe77a4857f6adaa4fc0dbbd8a3e3079a11d3 100644 --- a/Civi/FormProcessor/API/FormProcessor.php +++ b/Civi/FormProcessor/API/FormProcessor.php @@ -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']])) { diff --git a/Civi/FormProcessor/Type/DateType.php b/Civi/FormProcessor/Type/DateType.php index 33d5c7b46adff4fe628f4b73cbdfaffdee7bf776..a8ac83a1b5d44f5290449e8d4e678bf888d68b8b 100644 --- a/Civi/FormProcessor/Type/DateType.php +++ b/Civi/FormProcessor/Type/DateType.php @@ -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 + + } diff --git a/mkdocs.yml b/mkdocs.yml index 5ced9c7fb8e7541585762750bd03fa782c839e27..d3ec2421c722bb614abfd330ff74caaebe302af8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,8 +1,9 @@ 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