When I instantiate a new Checkboxes class (using the low_variables content type) and try to call the display_settings(), I get these errors:
Notice
Undefined index: field_fmt
ee/EllisLab/Addons/checkboxes/ft.checkboxes.php, line 335
Notice
Undefined index: field_pre_populate
ee/EllisLab/Addons/checkboxes/ft.checkboxes.php, line 349
Notice
Undefined index: field_list_items
ee/EllisLab/Addons/checkboxes/ft.checkboxes.php, line 353
Notice
Undefined index: field_pre_populate
ee/EllisLab/Addons/checkboxes/ft.checkboxes.php, line 361
Notice
Undefined index: field_pre_channel_id
ee/EllisLab/Addons/checkboxes/ft.checkboxes.php, line 366
Notice
Undefined index: field_pre_field_id
ee/EllisLab/Addons/checkboxes/ft.checkboxes.php, line 366These settings don’t have a default, apparently. What’s the best way to avoid this? Should fieldtypes have default settings for fallback? Or should I be approaching this in a different manner?
When saving settings for a File field, I’m getting:
Notice
Undefined index: field_content_type
ee/EllisLab/Addons/file/ft.file.php, line 710
Severity: E_NOTICE
Notice
Undefined index: allowed_directories
ee/EllisLab/Addons/file/ft.file.php, line 711
Severity: E_NOTICE
Notice
Undefined index: show_existing
ee/EllisLab/Addons/file/ft.file.php, line 712
Severity: E_NOTICE
Notice
Undefined index: num_existing
ee/EllisLab/Addons/file/ft.file.php, line 713
Severity: E_NOTICEThe save_settings method looks at the given data. Should I pass through the entire POST, or should the fieldtype check for data and then fall back to POST data?
The Grid array is more of a convenience so the developer doesn’t have to dig into a nested POST array for their settings. So yes, while it’s technically inconsistent, the developer experience is much better. If they ever end up needing more easily-accessible data in that array (hasn’t happened yet), it’s easy to add it to the existing array (where they expect) without them needing to change how they access that data with long ternaries, as you’re suggesting
Yes, adding checks in every field would technically be “consistent,” but I’m talking about the method to which you access your settings. That would suddenly become inconsistent and you would need to tell all the developers who want to make fieldtypes for your add-on to pull from POST and the $data array. It’s only “error prone” if the implementer of the content type wants to choose an inconsistent way of passing data to the fieldtype. You’re creating the errors then asking others to accommodate you.
Yes, obviously different ideas about elegance.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.