User tests: Successful: Unsuccessful:
Pull Request for Issue #33144
This PR changes the CSS class and styling applied to the input type=radio's label. Refer to
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
<label class="form-check-label" for="exampleRadios1">
Default radio
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
<label class="form-check-label" for="exampleRadios2">
Second default radio
</label>
</div>
This PR changes the form-check
class applied to each option's <label>
to form-check-label
and encloses each option's input-label pair in a <div class="form-check">
Change the XML form for any plugin's admin console page to include a radio field like: (similar to the example in Joomla 4 docs)
<field
name="search_archived"
type="radio"
class="switcher"
label="LABEL_NAME"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
Note that there is NO layout="joomla.form.field.radio.switcher"
part.
Please also test for class="btn-group"
and class="btn-group-yesno"
For example, in the screenshots below I've removed line 37 from plugins/content/vote/vote.xml to achieve the desired testing condition
joomla-cms/plugins/content/vote/vote.xml
Line 37 in 2c30264
no class
btn-group
btn-group-yesno
layout="joomla.form.field.radio.switcher"
should be mentioned in the Joomla 4 Plugin Tutorial Page's XML Section for making radio fields with 2 options.
Status | New | ⇒ | Pending |
Category | ⇒ | Layout |
I have tested this item
Works as described.
Nice work @YatharthVyas - is that your first PR that's going to be merged for Joomla? If so, welcome on board and I look forward to seeing more soon.
Documentation Required label should be added: The layout parameter should be included in the documentation if it's not there as that should become best practice for extension developers going forward to give a consistent UX in the backend.
RTC.
@richard67 not sure what's happened there with the first test by @rjharishabh not triggering JTracker properly?
RTC.
@richard67 not sure what's happened there with the first test by @rjharishabh not triggering JTracker properly?
@particthistle commenting from github
I have tested this item
@particthistle @rjharishabh, Thanks for testing!
Nice work @YatharthVyas - is that your first PR that's going to be merged for Joomla? If so, welcome on board and I look forward to seeing more soon.
It's my second one that's about to be merged. I'm glad that you found it helpful and thanks for the kind words! I hope to contribute more
Sorry, the fix is incorrect.
This PR removes the extra styling applied to each option's
<label>
You have removed possibility to set a class per option
, that may come from $option->class
Need to check what exactly cause the issue, which class or which style, to make a proper fix.
I can give you a tip: Look in to if ($isBtnYesNo)
section, it not used in Joomla 4, the issue may come from there.
My tip is wrong sorry :)
Sorry, the fix is incorrect.
This PR removes the extra styling applied to each option's
<label>
You have removed possibility to set a class per
option
, that may come from$option->class
Need to check what exactly cause the issue, which class or which style, to make a proper fix.
I can give you a tip: Look in toif ($isBtnYesNo)
section, it not used in Joomla 4, the issue may come from there.
My tip is wrong sorry :)
The class is still being applied to the checkbox, it's just the label that is not re-using it again. I believe if you want to allow the users to add classes to both the option and label separately then there should be 2 different parameters for them. Doing so would require changes in the XML schema.
Also, the Joomla 3 docs (Link) say that the class is only used to make 'nice coloured buttons' so it feels like the style must only be applied on the buttons, no?
Please correct me if I'm wrong and thanks for the feedback!
The class is still being applied to the checkbox
That is correct, if $option->class
exists then it should be applied.
The issue comes from class .form-check
, which applied to label, that is incorrect.
Bootstrap doc: https://getbootstrap.com/docs/5.0/forms/checks-radios/#default-stacked
That looks like the markup of radiobutons may need to review, to fit the doc.
You can try to look in to the checboxes layout joomla.form.field.checkboxes
, there seems correct markup
Or maybe someone from frontender can give you a tip.
@ciar4n do you have a tip here? ;)
There is something not right with this PR. You have removed $optionClass from the label but that would appear to have been the only place it was used so you should also have removed all the code that created it as well.
Labels |
Added:
?
|
Added the class="<?php echo trim($optionClass . ' ' . $style); ?>"
back to the label
And made the layout bootstrap friendly
thanks @Fedik for the help!
I have tested this item
Tested again. Changes now do what the changes do, even more correctly than earlier in the day.
All four options tested.
I have tested this item
All four options tested.
Status | Pending | ⇒ | Ready to Commit |
RTC
Title |
|
The styling/markup for button group is not correct. See https://getbootstrap.com/docs/5.0/components/button-group/
Yes please.
Status | Ready to Commit | ⇒ | Pending |
Back to pending, see previous comments.
No spacing between buttons.
Labels |
Added:
?
|
No spacing between buttons.
Thanks, fixed.
<div class="btn-group radio">
<input class="btn-check" type="radio" id="jform_params_show_total_votes0" name="jform[params][show_total_votes]" value="0" checked="checked">
<label for="jform_params_show_total_votes0" class="btn btn-outline-secondary"> Hide </label>
<input class="btn-check" type="radio" id="jform_params_show_total_votes1" name="jform[params][show_total_votes]" value="1" >
<label for="jform_params_show_total_votes1" class="btn btn-outline-secondary">Show </label>
</div>
btn-group
btn-group-yesno
Labels |
Added:
?
Removed: ? |
Labels |
Removed:
?
|
I have tested this item
I did think the button groups didn't quite look right last test... that explains why now.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-04-20 06:51:14 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
|
Thank you for merging. Could you please add the Documentation Changes label for
layout="joomla.form.field.radio.switcher"
should be mentioned in the Joomla 4 Plugin Tutorial Page's XML Section for making radio fields with 2 options.
@YatharthVyas But in your description in section "Documentation Changes Required" you wrote:
None, if the PR is merged.
Apologies but it was later that I realized that class="switcher" (the current class attribute mentioned in Joomla 4 Plugin Docs XML section) isn't a valid attribute. It should be one of the following :
layout="joomla.form.field.radio.switcher"
class="btn-group"
class="btn-group-yesno"
I forgot the edit and correct this part.
This PR removes the ability to set custom class names.
It is now not able to do something like:
<field name="..." type="radio"
class="btn-group btn-group-yesno my-own-class">
I have tested this item✅ successfully on 69ce6cb