New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[com_fields] Encode complex values to JSON #19025
Conversation
This adjustment allows complex field types (types with more than one input) to store and retrieve data.
plugins/system/fields/fields.php
Outdated
@@ -90,6 +90,11 @@ public function onContentAfterSave($context, $item, $isNew, $data = array()) | |||
// Determine the value if it is available from the data | |||
$value = key_exists($field->name, $fieldsData) ? $fieldsData[$field->name] : null; | |||
|
|||
// JSON encode value for complex fields | |||
if(is_array($value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix coding style as follows:
if (is_array($value))
{
No need, we're still branch merging things up so anything going into 3.x eventually lands on 4.0. |
plugins/system/fields/fields.php
Outdated
{ | ||
$value = json_encode($value); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please remove tabs on line 98.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
single dimension arrays are already handled, so this alteration changes the behavior to limit the effect to multi-dimensional arrays.
Anyone wanting to test this - I have made a field plugin that creates a multi-dimensional value, but I would rather not post it publicly. |
Hi stutteringp0et, I would like to test it, but can you give me the testing-instructions This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19025. |
@Joomill - I'll send you a message through the email address on your website. I haven't released the custom plugin and I'd like to keep it under wraps until I can release it. I had a look at your site and extensions, so I think you'll understand why. edit - email sent |
I have tested this item ✅ successfully on 13533fb This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19025. |
Thanks for taking the time @Joomill |
I have tested this item ✅ successfully on 13533fb This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19025. |
Ready to Commit after two successful tests. |
Yay! |
* Minor adjustment to field value This adjustment allows complex field types (types with more than one input) to store and retrieve data. * coding style compliance * coding style compliance * more rigorous test single dimension arrays are already handled, so this alteration changes the behavior to limit the effect to multi-dimensional arrays. * Update fields.php
This adjustment allows complex field types (types with more than one input) to store and retrieve data.
I'll be submitting this on the 4.0-dev branch as well
Summary of Changes
Test value before save, if it's a multidimensional array, json encode it
Testing Instructions
Hard to say without installing a 3rd party custom field plugin
Expected result
it should be transparent
Actual result
transparent on my end
Documentation Changes Required
none