BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
FieldSave save() method throws error if 'placeholder' or $fieldData are empty
#14 opened by obfuscode
Description
Was getting undefined index and invalid foreach. So I modified the following lines:
/system/user/addons/ansel/Controller/Field/FieldSave.php [Lines 75-81]:
Original:
// Unset the placeholder
unset($fieldData['placeholder']);
// If there is no field data, we can end
if (! $fieldData) {
return;
}
Updated:
// Unset the placeholder
if(!empty($fieldData['placeholder'])) unset($fieldData['placeholder']);
// If there is no field data, we can end
if (empty($fieldData)) {
return;
}
Replies
- TJ Draper
Replied 4/17/2017 7:13 PM, Edited 4/24/2017 12:11 PM
I’m curious how the FieldSave controller is getting a
$fieldData
array that is empty? There shouldn't be any circumstances under which Ansel natively send the$fieldSave
controller an array that does not have the placeholder item.That said, I can probably implement this, it's a fairly innocuous change.
- obfuscode
Replied 4/17/2017 7:16 PM, Edited 4/24/2017 12:11 PM
This is on a site that was running Ansel 1.4 and then upgraded to Ansel 2 so the data was whatever was saved in the system already.
- TJ Draper
Replied 4/17/2017 7:19 PM, Edited 4/24/2017 12:11 PM
Ansel never passes raw data from the field back into any save methods, though — or it's not supposed to. The raw field data in the
channel_data
column for Ansel's field is really a by-product and no longer considered any good after the field has been saved. Which is why I’m asking how Ansel is getting an array that doesn't have a placeholder. It should always be there any time Ansel is calling the FieldSave controller.