? NPM Resource Changed ? ? Pending

User tests: Successful: Unsuccessful:

avatar continga
continga
23 Apr 2019

Summary of Changes

This is a new version of PR #22446 . We had a long discussion in #22446 about the feature of a subfields custom field, and after some feedback-cycles we came up with a good solution.

Sadly, that PR couldn't make it into the 3.x-branch, hence we need to rebase the whole PR and create a new one against 4.0-dev. This is the purpose of this PR. It will implement the functionality from #22446 into the 4.0-dev branch.

Testing Instructions

See #22446 - basically what needs to be tested is the new "Subfields" custom field type, which can contain other custom field instances. It is basically a collection of other custom fields.

We need to check both the correct behaviour in the backend (entering custom field data, editing custom fields), as well as the default-display in the frontend (outputting all kind of different subfields+fields values, etc). See also further down at the docs-link.

Expected result

See #22446

Documentation Changes Required

Yes. I have started to work on it a bit, see https://docs.joomla.org/Custom_fields_type:_Subfields

I will update that docs-page over the coming weeks, it is currently not reflecting the very latest changes. But it is already giving a good quick overview about the feature, and possible cases to test.

Additional information

I am very open for general code feedback, improvement ideas, test cases etc. I am not completely sure whether I followed all J4 coding-guidelines, so I would be glad to get some feedback and correct something - in case it's needed.

Generally, IMHO the feature is already very complex at the current state, so we should take distance from making it even more powerful. It makes more sense to get the current functionality merged, and then working on more advanced matters afterwards.

Also, it seems like choosing a category for a custom field currently seems broken in 4.0-dev generally, not only in this branch? Seems to be caused by an exception being thrown at

$cat = $componentObject->getCategory([], $section ?: '');
This needs to be investigated, but it ain't part of this PR. Just dropping this note here, because I think testers will stumble accross not being able to set a category for a custom field.

Summoning @regularlabs @AndySDH - you guys did a great job at testing the previous PR, maybe you could take a look at this one? :)

avatar continga continga - open - 23 Apr 2019
avatar continga continga - change - 23 Apr 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Apr 2019
Category SQL Administration com_admin Postgresql com_fields Language & Strings JavaScript Repository NPM Change Front End Installation Libraries Plugins
avatar continga continga - change - 24 Apr 2019
Labels Added: ? NPM Resource Changed ?
avatar franz-wohlkoenig franz-wohlkoenig - change - 24 Apr 2019
Title
Fields subfields 4.0
[4.0] Fields subfields
avatar franz-wohlkoenig franz-wohlkoenig - change - 24 Apr 2019
Title
Fields subfields 4.0
[4.0] Fields subfields
avatar franz-wohlkoenig franz-wohlkoenig - edited - 24 Apr 2019
avatar ghazal
ghazal - comment - 24 Apr 2019

Tested but "Sub field *" dropdown doesn't show.


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

avatar AndySDH
AndySDH - comment - 24 Apr 2019

Thanks a lot for your work!

I'll post things as I find them... :)

image

A few notes about this...

  1. Looks like Joomla 4 switched the true/false stuff to a toggle? See the "Required" option.
    So I'm guessing to keep it consistent, all the Yes/No stuff you have ("Repeatable" option and "Render values" options) should be changed to the same way of doing things? Not sure.

  2. Looks like the option descriptions for "Sub field" and "Render values get repeated for every row instead of just being at the top for some reason. So this unnecessary and should be probably removed and only displayed at the top.

  3. As it can obviously be seen, those long options descriptions break the layout and they don't wrap to new lines. But this is probably a general issue that has nothing to do with this PR. (such as the one you already mentioned for not being able to select a Category)

avatar ghazal
ghazal - comment - 24 Apr 2019

Sorry. After @AndySDH post, I understood my mistake.
Dropdown works allright.

avatar AndySDH
AndySDH - comment - 24 Apr 2019

Some more stuff:

  1. In article view, the layout doesn't seem to stack on mobile view
  2. This issue is back:

Issue with a calendar sub field: First filling (and saving) and then emptying a calendar sub field, makes it still store in the database value as "0000-00-00 00:00:00", and outputs it as "-0001-11-30". Instead if should obviously not be stored when empty.

  1. Looks like there is space output around the subfield values, such as:
    image

  2. So as we know, Repeatable Field needs to be gone in Joomla 4.0. So just a reminder that something will have to be done with this:
    #23659

Don't see anything else for now! :)

avatar ghazal
ghazal - comment - 25 Apr 2019

I have tested this item successfully on 174a97a

I really hope this will be implemented.


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

avatar ghazal
ghazal - comment - 25 Apr 2019

I have tested this item successfully on 174a97a

I really hope this will be implemented.


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

avatar ghazal ghazal - test_item - 25 Apr 2019 - Tested successfully
avatar sanderpotjer
sanderpotjer - comment - 4 May 2019

@continga great work, thanks! Besides the feedback already shared by others i found an issue with the media field: The Media field is trowing JavaScript error if the article with field is not saved yet. Uncaught TypeError: this.querySelector(...).open is not a function, so the media model is not opening

avatar HLeithner
HLeithner - comment - 13 May 2019

@continga could you please resolve the conflicts?

avatar AndySDH
AndySDH - comment - 19 Aug 2019

Any update @continga? Just making sure we don't forget this for Joomla 4! If @continga is not available, can someone else fix the conflicts?

avatar continga continga - change - 4 Sep 2019
Labels Added: ?
avatar continga
continga - comment - 4 Sep 2019

Hi all, I just pushed an update for this which contains merging against 4.0-dev and some smaller bugfixes. Can y'all take a look again and report any last stuff? I am pretty sure we can somehow get this merged soon then yet.

PS: I don't know why the drone build is failing, looks like a CI failure and not something I have done wrong?

Note for testing: Currently, the selection of the sub fields stretches wide to the right, effectively overlaying with the content box to the right, hence not being able to use the add/remove/reorder buttons of the subform, see this screenshot:

image

This is being caused by the description of the top-row being way too long, and until we decide on a solution for this (maybe somehow just hide the description there, or implement this hotfix) there is a hotfix available to be able to use the page: Right-click on the "Render values" table header -> "Inspect element", remove the CSS rule "white-space: nowrap;", see screenshot:

image

Then the layout looks better, not completely OK yet, but it is useable:

image

avatar continga
continga - comment - 4 Sep 2019

@AndySDH I am not sure whether I understand your concern incorrectly, or whether you're wrong.

$row_output is an array containing the output of the subfields for one single row. So $row_output is the output for a single row. That is exactly what the variable name says. It is not the output of a single subfield inside a row - that is just what an array member of $row_output is.

Same for $result: It contains the overall result for all rows, not the output of a row. I also here think the name is correct.

avatar AndySDH
AndySDH - comment - 8 Sep 2019

@AndySDH I am not sure whether I understand your concern incorrectly, or whether you're wrong.

$row_output is an array containing the output of the subfields for one single row. So $row_output is the output for a single row. That is exactly what the variable name says. It is not the output of a single subfield inside a row - that is just what an array member of $row_output is.

Same for $result: It contains the overall result for all rows, not the output of a row. I also here think the name is correct.

Yup, you are right. I was thinking individual elements of the array instead of the whole array. It's actually good as it is :)

avatar AndySDH
AndySDH - comment - 8 Sep 2019

So... I tested this with the latest J4 Alpha dev 12. The core backend template layout is still a complete mess so I'm not sure I'm able to judge this accurately when it comes to appearance.

Functionality wise:

  • Still an issue from before: Issue with a calendar sub field: First filling (and saving) and then emptying a calendar sub field, makes it still store in the database value as "0000-00-00 00:00:00", and outputs it as "-0001-11-30". Instead if should not be stored when empty.

  • The "Repeatable" option currently can be changed after a subfield already exists. We figured it should not be possible to change it due to it messing up the values when changed.

I'll list what I can when it comes to appearance:

  • As you already mentioned, it makes no sense for there being a nowrap CSS rule for th, it's only going to mess things up, so that should definitely be fixed in the Joomla template.

  • Still an issue from before: When creating a subfield, the option descriptions for "Sub field" and "Render values get repeated for every row instead of just being at the top for some reason. So this unnecessary and should be probably removed and only displayed once at the top in the thead.

  • Looks like now the Joomla template displays input fields side-by-side instead of stacking. In article edit form, the subfields type can't really coexist side by side with anything, as it's a table display in the first place, so its control-group should always be forced to a new line and width 100%. See below the current situation:

terrible

But again, the whole Joomla Backend template is pretty terrible right now so idk.

  • Still an issue from before: In article edit form, the layout doesn't stack on mobile view
avatar continga continga - change - 11 Oct 2019
Labels Added: ?
Removed: ?
avatar continga
continga - comment - 11 Oct 2019

Ok, how do we continue with this PR? I feel like the collective effort to get this merged is not very high, which I think is kind of sad after having received so much positive feedback ealier and after having spent so much work into this.

What we should do, from my point of view: We merge this into 4.0-dev now. The codebase for this PR is over one year old (see #22446), and no major issues have been found for a long time, and we had many different tests from different people in that timeframe. There are maybe 2 minor issues present at this time, and I will very gladly fix them after this got merged, because then I know my work is not being a pure waste of time. Additionally, we then get enough time to test this together with the whole community and react on possible problems.

The other possibility would be to just close this PR, as we would never get this merged otherwise. Joomla 4 Beta is about to sail away this month, and if we don't get this into beta we can just close it already.

What do we do?

avatar HLeithner
HLeithner - comment - 11 Oct 2019

iirc #23659 is missing for j4 incl. migration of old fields. ymmv

avatar continga
continga - comment - 11 Oct 2019

It is not "missing" in the sense of "it is required to be done" - it just makes sense to remove the repeatable type when this PR got merged, because the new type can do the same as the (then obsolete) repeatable type.

I will happily work on #23659 incl. a migration when we got this PR merged.

avatar AndySDH
AndySDH - comment - 12 Oct 2019

Yes, this absolutely needs to be merged asap! @wilsonge

avatar wilsonge wilsonge - change - 13 Oct 2019
Labels Added: ?
Removed: ?
avatar wilsonge
wilsonge - comment - 13 Oct 2019

Can we get a test of this done fully please. And I'm happy to get this merged before we tag the next alpha on Thursday and I'll rely on you keeping to your word on the upgrade script (which is essential)

avatar AndySDH
AndySDH - comment - 13 Oct 2019

Test was fully done, only minor things left to address are in my previous comment on September 8.

avatar wilsonge wilsonge - change - 13 Oct 2019
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-10-13 11:15:19
Closed_By wilsonge
Labels Added: ?
Removed: ?
avatar wilsonge wilsonge - close - 13 Oct 2019
avatar wilsonge wilsonge - merge - 13 Oct 2019
avatar wilsonge
wilsonge - comment - 13 Oct 2019

OK. Then I'm happy to commit. @continga please ensure you at least sort the migration script and the calendar null date issue

avatar richard67
richard67 - comment - 13 Oct 2019

@wilsonge

@continga please ensure you at least sort the migration script and the calendar null date issue

If you mean the null date usage in the insert statement for the extensions table in the joomla.sql files and the update sql files: This will be fixed with my PR #26491 . I've updated it so it contains the changes from this PR here and then corrects the nulldates for the checked_out_time columns to real null values like for all other extensions.

avatar richard67
richard67 - comment - 18 Oct 2019

@Quy Could be maybe ok because on js side, will possibily be set to the right value when writing to db in php. I will check later today or tomorrow.

avatar Quy
Quy - comment - 18 Oct 2019

@continga Invalid argument supplied for foreach() in \libraries\src\Form\FormField.php on line 1124

To reproduce:

  • Create a subform field
  • Edit an article (leave subform field empty)
  • Save the article
  • Check PHP error log
avatar AndySDH
AndySDH - comment - 11 Nov 2019

@continga Woud be good if you could add an option for Repeatable Subfields to select a maximum number of rows that can be added (how many times it can be repeated).

avatar AndySDH
AndySDH - comment - 30 Nov 2019

@continga Remember to look after any possible tweak, fixes, and the implementation of the migration script happening. The PR has been merged like you requested, now please don't just forget about it :P

avatar micker
micker - comment - 4 Dec 2019

hello 2 questions about migration of repetable field to subfield
did you have some information about better migration ?
did you think we can have subfield for j3 to prepare a smother migration ?

avatar AndySDH
AndySDH - comment - 5 Dec 2019

Well, a PR was ready for 3.9, but it got asked to be rebased for 4.0
See: #22446

Add a Comment

Login with GitHub to post a comment