Skip to content

Inputfield config values using checkbox are not loaded from Field object #1353

Open
@Toutouwai

Description

@Toutouwai

Short description of the issue

If you have an inputfield module used in conjunction with PW field then the inputfield config settings are supposed to be loaded from the Field object. You would typically define default values for the inputfield config in the constructor and then in Field::getInputfield() the Field object's data array is looped over, and for each key if the inputfield has a setting or attribute with that name then the value is passed from the Field object to the Inputfield object, overriding the default value.

https://github.com/processwire/processwire/blob/c77f2f0d63dfa1fc28ed0854b9c0a41567cdfe2f/wire/core/Field.php#L963-L974

But if the config field for the inputfield module uses a checkbox then no data is stored for the config field if the checkbox is submitted unchecked, and therefore the data array for the Field object doesn't include the config field name. So if you have a config setting that uses a checkbox and the default value is checked (as set in the constructor) but the setting stored in the Field object is unchecked then the config setting is not correctly loaded as unchecked.

It seems like PW should handle this scenario so that a checkbox can be used in inputfield module configs the same as any other config inputfield. Not sure how exactly. Maybe in Field::getInputfield() instead of looping over the Field object's data array and checking for matching settings in the Inputfield object it should be the other way around: loop over the Inputfield object's data and check for matching settings in the Field object.

Setup/Environment

  • ProcessWire version: 3.0.174

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions