Closed (fixed)
Project:
Taarikh
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Oct 2019 at 16:44 UTC
Updated:
20 Oct 2019 at 16:49 UTC
Jump to comment: Most recent
If a form is using Ajax (even in other fields), the form breaks if the date field is not set before invoking the Ajax callback. For example, in my form, there is an entity browser and if I attempt to load the modal browser without filling in the date field, nothing happens and there is an error reported in the console.
Internal Server Error
ResponseText: The website encountered an unexpected error. Please try again later.InvalidArgumentException: The date cannot be created from a format. in Drupal\Component\Datetime\DateTimePlus::createFromFormat() (line 248 of core/lib/Drupal/Component/Datetime/DateTimePlus.php). Drupal\taarikh\Element\TaarikhDatetime::validateDatetime(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 282)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object) (Line: 238)
...The problem is that the element is not making any checks before attempting to construct the DateTimePlus object from the format, and this exception is thrown.
We should add checks before attempting to construct this object.
Comments
Comment #3
hussainwebCommitted the fix.