verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
94 stars 70 forks source link

Date field error when "Default Date/Time" is left empty #1344

Closed friartuck6000 closed 1 month ago

friartuck6000 commented 1 year ago

Describe the bug

When building/editing a Date field, it's possible for an editor to set Default Value to "Custom Date/Time", but leave the Default Date/Time setting empty:

Screenshot 2023-03-09 at 11 01 59 AM

When using the "Dropdowns" or "Text Inputs" Display Type, this results in an error:

Call to a member function format() on array at <plugin-path>/src/fields/formfields/Date.php:1375

Ideally, I think the Default Date/Time field would include the required validation and prevent an editor from saving the field in that state to begin with; but with that aside, I would have expected an empty custom date to ultimately behave the same as setting the default to "None".

Steps to reproduce

  1. Create a Date field.
  2. For Default Value, choose "Custom Date/Time".
  3. Leave Default Date/Time unset.
  4. Set Display Type to either "Dropdowns" or "Text Inputs".
  5. Save the form, and attempt to view it on a page.

Form settings

Craft CMS version

4.3.9

Plugin version

2.0.24

Multi-site?

No response

Additional context

No response

engram-design commented 1 year ago

Thanks for the PR!

And as for the lack of FormKit validation, that's just a tricky one that we'd need a custom validator for, because technically the setting has a value of {date: '', timezone: ''} for an empty date/time field control, otherwise adding 'validation' => 'required' to the field settings schema would do.

engram-design commented 1 month ago

Updated in 3.0.0