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

Projects
None yet
6 participants
@stutteringp0et
Copy link
Contributor

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

Minor adjustment to field value
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)) {

This comment has been minimized.

@Quy

Quy Dec 8, 2017

Contributor

Please fix coding style as follows:

if (is_array($value))
{
@mbabker

This comment has been minimized.

Copy link
Member

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);
}

This comment has been minimized.

@Quy

Quy Dec 8, 2017

Contributor

Also please remove tabs on line 98.

This comment has been minimized.

@stutteringp0et

stutteringp0et Dec 8, 2017

Contributor

done

stutteringp0et and others added some commits Dec 8, 2017

more rigorous test
single dimension arrays are already handled, so this alteration changes the behavior to limit the effect to multi-dimensional arrays.
@stutteringp0et

This comment has been minimized.

Copy link
Contributor

stutteringp0et commented Dec 10, 2017

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.

@Joomill

This comment has been minimized.

Copy link

Joomill commented Dec 11, 2017

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

This comment has been minimized.

Copy link
Contributor

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

@Joomill

This comment has been minimized.

Copy link

Joomill commented Dec 11, 2017

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

This comment has been minimized.

Copy link
Contributor

stutteringp0et commented Dec 11, 2017

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

Quy commented Dec 18, 2017

Ready to Commit after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC label Dec 18, 2017

@stutteringp0et

This comment has been minimized.

Copy link
Contributor

stutteringp0et commented Dec 19, 2017

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

5 checks passed

JTracker/HumanTestResults Human Test Results: 2 Successful 0 Failed.
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/drone/pr the build was successful
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound No violations found. Woof!

@joomla-cms-bot joomla-cms-bot removed the RTC label Dec 21, 2017

photodude added a commit to photodude/joomla-cms that referenced this pull request Dec 25, 2017

[com_fields] Encode complex values to JSON (joomla#19025)
* 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