Problem/Motivation

Pathauto includes a path field widget that overrides the base path field widget by adding a checkbox to automatically generate a URL alias. On standard entity forms the state of the textfield is dependent on the state of the checkbox and so checking the box would ordinarily disable input to the textfield. However by altering the form structure, using a non-standard field name or embedding the form using the inline_entity_form module the interaction between the two form elements breaks.

Proposed resolution

The issue appears to be caused by the state being hard-coded to target the path element. If for whatever reason the field was named differently or was placed within another form element (as is the case with using inline_entity_form) then this no longer works. I have not looked into whether a non-standard field name is supported by the module however I have briefly tested adding the contents of the $element['#field_parents'] to the state selector and the result was a success inside the embedded form.

The proposed solution would therefore be to generate the states selector using the field parents, field name, delta and checkbox element key. I am not sure if there is a utility function to do so but it should be fairly simple array manipulation.

Comments

dbalcomb created an issue.

Berdir’s picture

Pathauto currently only supports fields that are named path. Changing that will not be that easy, we'd have to loop over all fields and look for path fields. We also always generate the field as 'path'. But yes, nested forms with e.g. IEF is a valid use case that we want to support.