? ? Pending

User tests: Successful: Unsuccessful:

avatar HLeithner
HLeithner
28 Oct 2021

Subform Field doesn't allow to set a value because the supplied value is automatically converted to string which is the wrong variable type for Subform Field. The Field needs an array.

Summary of Changes

This PR automatically converts a json encoded string into an array and allows to supply an array directly

Testing Instructions

  1. Create a custom field with a subform
  2. Test if the field still works in backend and frontend

Testing the new functionally is not so easy.
Editing the com_content default layout could be the simplest way.

You need to get the subform field from the form and set a value.

For a successful test I would expect that the simple test is enough.

Actual result BEFORE applying this Pull Request

  • Simple test works
  • Extended Test doesn't work

Expected result AFTER applying this Pull Request

  • Simple test works
  • Extended Test works
avatar HLeithner HLeithner - open - 28 Oct 2021
avatar HLeithner HLeithner - change - 28 Oct 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 28 Oct 2021
Category Libraries
avatar Fedik
Fedik - comment - 28 Oct 2021

we have that here also:

if ($this->value && \is_string($this->value))
{
// Guess here is the JSON string from 'default' attribute
$this->value = json_decode($this->value, true);
}

maybe also change there to avoid duplication?

avatar HLeithner HLeithner - change - 29 Oct 2021
Labels Added: ?
avatar HLeithner
HLeithner - comment - 29 Oct 2021

we have that here also:

if ($this->value && \is_string($this->value))
{
// Guess here is the JSON string from 'default' attribute
$this->value = json_decode($this->value, true);
}

maybe also change there to avoid duplication?

Not sure what you mean, isn't this the same code?
Maybe the cast to array should be removed by me and the use statement....

avatar Fedik
Fedik - comment - 29 Oct 2021

hm, ignore, my comment, sorry for confusing

Maybe the cast to array should be removed

yea, I think better to remove, or at least check if there any value,
because $this->value = (array) null; will produce [null]

avatar HLeithner
HLeithner - comment - 11 Nov 2021

@Fedik should be better now

avatar Fedik Fedik - test_item - 12 Nov 2021 - Tested successfully
avatar Fedik
Fedik - comment - 12 Nov 2021

I have tested this item successfully on c197842


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

avatar RickR2H RickR2H - test_item - 15 Dec 2021 - Tested successfully
avatar RickR2H
RickR2H - comment - 15 Dec 2021

I have tested this item successfully on c197842


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

avatar RickR2H RickR2H - change - 15 Dec 2021
Status Pending Ready to Commit
avatar RickR2H
RickR2H - comment - 15 Dec 2021

RTC


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

avatar wilsonge wilsonge - change - 4 Jan 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-01-04 00:44:33
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 4 Jan 2022
avatar wilsonge wilsonge - merge - 4 Jan 2022
avatar wilsonge
wilsonge - comment - 4 Jan 2022

Thanks!

Add a Comment

Login with GitHub to post a comment