Skip to content
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

Merged
merged 5 commits into from Dec 21, 2017

Conversation

stutteringp0et
Copy link
Contributor

@stutteringp0et stutteringp0et commented Dec 8, 2017

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

This adjustment allows complex field types (types with more than one input) to store and retrieve data.
@@ -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)) {
Copy link
Contributor

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))
{

@mbabker
Copy link
Contributor

mbabker commented Dec 8, 2017

I'll be submitting this on the 4.0-dev branch as well

No need, we're still branch merging things up so anything going into 3.x eventually lands on 4.0.

{
$value = json_encode($value);
}

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

stutteringp0et and others added 3 commits December 8, 2017 16:41
single dimension arrays are already handled, so this alteration changes the behavior to limit the effect to multi-dimensional arrays.
@stutteringp0et
Copy link
Contributor Author

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.

@JeroenMoolenschot
Copy link
Member

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.

@stutteringp0et
Copy link
Contributor Author

stutteringp0et commented Dec 11, 2017

@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

@JeroenMoolenschot
Copy link
Member

I have tested this item ✅ successfully on 13533fb

Subform is saved as: {"subform0":{"example_text":"value","example_textarea"...


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19025.

@stutteringp0et
Copy link
Contributor Author

Thanks for taking the time @Joomill

@stutteringp0et stutteringp0et changed the title Minor adjustment to field value [com_fields] Encode complex values to JSON Dec 14, 2017
@Quy
Copy link
Contributor

Quy commented Dec 18, 2017

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.

@Quy
Copy link
Contributor

Quy commented Dec 18, 2017

Ready to Commit after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Dec 18, 2017
@stutteringp0et
Copy link
Contributor Author

Yay!

@mbabker mbabker added this to the Joomla 3.8.4 milestone Dec 21, 2017
@mbabker mbabker merged commit 5339ba9 into joomla:staging Dec 21, 2017
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Dec 21, 2017
photodude pushed a commit to photodude/joomla-cms that referenced this pull request Dec 25, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants