-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Styling only works for the first repeatable item in Sub Form Fields #11299
Comments
For selects (type="list") to attach chosen JS (behaviour + styling)
For radios, do not use class="btn-group" !! instead
@Fedik Template styling can be supported if a new requirement for templates would be introduced:
(notice the "sel" that allow applying the stylings to a specific container)
The subform "addRow()" method, would call the above method
But now the above does not exist and we can not use it,
|
The solution of hard-coding the JS-based styling is what i do myself now,
But currently great majority of templates
Thus best solution is to
the above is B/C friendly too |
no, it is bad solution Just need to accept that we need the Events API for interact between different part of fronted scripts, and stop hardcoding. Also I seen some idea on JAB 2016 |
Hard coding is what templates are doing now, i suggested to stop doing it, About events API , i would say yes , and since this is to be added,
Now about not hard-coding it inside the subform field, i will disagree
thus it can be replaced when the other solutions are available without a B/C break ? ! |
bad argumen, you know 😄
as practice shows mostly every temporary thing stays forever 😉 The subform field has event $(document).on('subform-row-add', function(event, row){
// here is the code to do some stuff with the field in `row`
}); |
yes
yes , and now that i think of it is not "worthy" enough of a temporary solution ?
|
Then what needs to be done for this issue is to document requirements ??:
|
yes, for make <field name="languagesub" type="list" class="advancedSelect" ... for "btn-group": if there a way do not use JavaScript, it would be perfect, otherwise need to tweak a script in template.js to make it work. Some one can use a fix from a closed PR template.js#L10 as example (need just replace $(document).on('subform-row-add', function(event, row){
// here is the code to make "btn-group" work
}); |
Well, the Documentation for Subforms is really sparse at the moment. The only usable description of the different types of formats of subforms was on stackoverflow. Maybe I didn't look at the right places, but right now, there is nothing about sub form fields in form fields, nor repeatable fields, even though the code for repeatable fields already mentions that they are deprecated and that sub form fields should be used instead. Even the release announcements for 3.6.0 praised subforms without pointing to any usage instructions! Anyways, I'm going to try the fix with assigning the additional class to the list. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11299. |
you original issue had usage description: but it never made into documentation ? , i see user posted it to stackoverflow About attaching bootstrap behaviour / styling and making possible to use:
|
Ok now i have lost you,
A mistake was that a new property was not added to JFormField Class , And then
|
Oh, I just assumed that subforms were supposed to work with any JFormField class, my bad. So I will have to go back to using text fields for repeatable calendar dates then? |
Test which fields work,
it is natural that you assumed that all fields would work ! about calendar fields, i guess you should use text input for now |
the subform field work with all fields, it just not all fields works with subform field 😄 Mostly fields that have additional javascript logic are broken, because they did not made to live in the dynamic world. If you set There already was issue about this, cannot find. |
@Fedik This one is probably related, since it's also javascript logic (In this case styled radio buttons) being broken upon creating additional sub form fields: #10718 |
@ggppdk You said "also it is undocumented which Joomla form fields types are have been tested to work with it" does someone know which ones are tested? If so, we should ask to update the documentation at https://docs.joomla.org/index.php?title=Subform_form_field_type "the stylings are not a bug, some better documentation will help avoid frustration " This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11299. |
I can confirm the sample code given by @ggppdk works works when added to the layout file although I had to use jQuery instead of $, presumably because of Bootstrap. |
The cause of radio button groups not being styled is because groups in the initial page load are styled by code in template.js, and this code is not run when new button groups are created by subform-repeatable.js. The same is true of Chosen dropdown styling. I will fix this - by moving the code into a global function which is called from template.js but can also be called from subform-repeatable.js. If anyone disagrees with this approach please comment now to avoid me wasting effort on a PR which will not be merged. |
exactly what i said in this issue and in a different issue a year or more ago maybe now nobody will complain about it and your PR will be merged Quoting my comment
thus template specific styling can be applied i think the negative comment about the above, is that a complete interface or something should be defined that templates will use, i don't remember exactly |
I have done this in a way that we do not need a new standard JS method. Although I have used a standard method in isis, protostar and beez, it doesn't need to be. Instead I use the subform.row.add jQuery event to style the new subform row. |
You have done exactly what i was talking above,
so there is nothing different about it instead of calling it you called it |
Nope - using events was what other people were suggesting whilst you were suggesting that the new method was called directly from subform add by having a standardised method name. |
yes it is as you say and it is really not a good idea |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/11299 |
closed as having Pull Request #19722 |
Steps to reproduce the issue
create a form.xml to display:
``
create a subform.xml (use it's file location for the formsource in the form.xml):
basic communication skills (A1/A2) good command (B1) very good command (B2) highly proficient (C1) near native (C2) native ``
Expected result
All repetitions of the sub form field should be styled the same.
Actual result
Only the first item is styled correctly.
System information (as much as possible)
Joomla 3.6.0
Template in the screenshot is based on protostar, but error was reproducible using all other templates that were installed (protostar and beez3)
The text was updated successfully, but these errors were encountered: