Problem/Motivation

Follow-on from #3619470: "Add another item" button doesn't work after deleting all the dates, the smart_date library is attached to the form rather than the element.

This means that when the smart date field is dynamically added with AJAX, the smart_date library doesn't get attached to the new page resulting in it being broken and missing functionality like the "All day" checkbox.

Steps to reproduce

1. Have a required recurring date field saved on a node.
2. Using the "Smart Date | Inline range" widget, remove all the date field values, so there is nothing left.
3. Save the page. It should fail because the field is required, but have no smart_date widgets attached.
4. Now the widget is added, but without any of the necessary CSS or JS applied.

Proposed resolution

Attach the library on the $element rather than the $form, that way it can bubble up to the necessary form, as well as allow it to be attached on AJAX request.

Remaining tasks

Provide MR.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork smart_date-3619653

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

codebymikey created an issue. See original summary.

codebymikey’s picture

Status: Active » Needs review
codebymikey’s picture

Assigned: codebymikey » Unassigned
Issue summary: View changes