Skip to content

[4.0] Fields subfields#24711

Merged
wilsonge merged 26 commits intojoomla:4.0-devfrom
continga:fields-subfields-4.0
Oct 13, 2019
Merged

[4.0] Fields subfields#24711
wilsonge merged 26 commits intojoomla:4.0-devfrom
continga:fields-subfields-4.0

Conversation

@continga
Copy link
Copy Markdown

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? :)

Rene Pasing added 5 commits April 15, 2019 19:55
…, squashed.

This already contains adjustments for Joomla! 4, e.g. changed class files / paths, etc.
This does not yet contain any tests made or bugfixes against the 4.0 branch. This will
be done after this commit and possible bugfixes will be made in standalone commits.
So this basically only contains the code from joomla#22446, adjusted to the 4.0 directory structure.
@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators NPM Resource Changed This Pull Request can't be tested by Patchtester PR-4.0-dev labels Apr 23, 2019
@ghost ghost changed the title Fields subfields 4.0 [4.0] Fields subfields Apr 24, 2019
@ghazal
Copy link
Copy Markdown
Contributor

ghazal commented Apr 24, 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.

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Apr 24, 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)

@ghazal
Copy link
Copy Markdown
Contributor

ghazal commented Apr 24, 2019

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

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Apr 24, 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:
    [4.0] Remove plg_fields_repeatable #23659

Don't see anything else for now! :)

@ghazal
Copy link
Copy Markdown
Contributor

ghazal commented Apr 25, 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.

@sanderpotjer
Copy link
Copy Markdown
Member

@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

@HLeithner
Copy link
Copy Markdown
Member

@continga could you please resolve the conflicts?

@Quy Quy added the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label Jul 14, 2019
@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Aug 19, 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?

@continga
Copy link
Copy Markdown
Author

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?

@HLeithner
Copy link
Copy Markdown
Member

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

@continga
Copy link
Copy Markdown
Author

continga commented Oct 11, 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.

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Oct 12, 2019

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

@wilsonge
Copy link
Copy Markdown
Contributor

wilsonge commented Oct 13, 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)

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Oct 13, 2019

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

@wilsonge wilsonge merged commit 87f590c into joomla:4.0-dev Oct 13, 2019
@wilsonge
Copy link
Copy Markdown
Contributor

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

@wilsonge wilsonge added this to the Joomla 4.0 milestone Oct 13, 2019
@wilsonge wilsonge added Documentation Required and removed Updates Requested Indicates that this pull request needs an update from the author and should not be tested. labels Oct 13, 2019
@richard67
Copy link
Copy Markdown
Member

@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.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 18, 2019

@richard67
Copy link
Copy Markdown
Member

@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.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Oct 18, 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

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Nov 11, 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).

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Nov 30, 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

@micker
Copy link
Copy Markdown

micker commented Dec 4, 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 ?

@AndySDH
Copy link
Copy Markdown
Contributor

AndySDH commented Dec 5, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Required Language Change This is for Translators NPM Resource Changed This Pull Request can't be tested by Patchtester

Projects

None yet

Development

Successfully merging this pull request may close these issues.