There are 3 fields involved in my I've done.
First, I created a list field named repeat_type
<field name="repeat_type" type="list" label="REPEAT_TYPE_LABEL" description="REPEAT_TYPE_DESC" labelclass="ch-w-full" > <option value="0">OPTION_EVENT_NO_REOCCURENCE</option> <option value="1">OPTION_EVENT_DAILY</option> <option value="2">OPTION_EVENT_WEEKLY</option> <option value="3">OPTION_EVENT_MONTHLY</option> <option value="4">OPTION_EVENT_CUSTOM</option> </field>
Second, create a radio field with class="btn-group btn-group-yesno"
then add a showon
attribute so it only show when value 3 (OPTION_EVENT_MONTHLY) is selected.
<field name="monthly_by_day_or_weekday" type="radio" label="MONTHLY_REOCCURENCE_BY_DAY_OR_WEEKDAY_LABEL" description="MONTHLY_REOCCURENCE_BY_DAY_OR_WEEKDAY_DESC" class="btn-group btn-group-yesno" default="1" showon="repeat_type:3" > <option value="1">OPTION_EVENT_MONTHLY_REOCCURENCE_SELECT_BY_DAY</option> <option value="0">MONTHLY_REOCCURENCE_SELECT_BY_WEEKDAY</option> </field>
Third, create two fields: monthly_by_day
and monthly_by_weekday
<field name="monthly_by_day" type="list" default="" label="MONTHLY_REOCCURENCE_DAY_OF_MONTH_LABEL" description="MONTHLY_REOCCURENCE_DAY_OF_MONTH_DESC" showon="repeat_type:3[AND]monthly_by_day_or_weekday:1" > <option value="">MONTHLY_REOCCURENCE_SELECT_DAY_OF_MONTH</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </field>
Then
<field name="monthly_by_weekday" type="list" default="" multiple="true" label="MONTHLY_REOCCURENCE_WEEK_OF_MONTH_LABEL" description="MONTHLY_REOCCURENCE_WEEK_OF_MONTH_DESC" showon="repeat_type:3[AND]monthly_by_day_or_weekday:0" > <option value="">OPTION_SELECT_A_WEEK_NAME</option> <option value="1">OPTION_SELECT_A_WEEK_NAME_MONDAY</option> <option value="2">OPTION_SELECT_A_WEEK_NAME_TUESDAY</option> <option value="3">OPTION_SELECT_A_WEEK_NAME_WEDNESDAY</option> <option value="4">OPTION_SELECT_A_WEEK_NAME_THURSDAY</option> <option value="5">OPTION_SELECT_A_WEEK_NAME_FRIDAY</option> <option value="6">OPTION_SELECT_A_WEEK_NAME_SATURDAY</option> <option value="7">OPTION_SELECT_A_WEEK_NAME_SUNDAY</option> </field>
In the field monthly_by_day_or_weekday
, if I select option 1, only the field named monthly_by_day
will be shown or if I select option 2 only the field named monthly_by_weekday
will be shown. But...
In the field setting, field monthly_by_day
will be shown since it is the default. But when I click on option 2, the field monthly_by_day
is still showing. But if I refresh the page, option 2 is now the default and it will show monthly_by_weekday
. What I'm trying to say is the shownon
toggle is not working with radio field.
As of Sunday, 21 October 2018 02:00:33 UTC update package, refreshing the page no longer change anything. It will only show whatever default option set in the field monthly_by_day_or_weekday
.
Here's a screen capture:
Labels |
Added:
?
|
It's my fault I guess, the new code is using some aggressive caching (the old one recalculated everything on each change). Obviously the old way (no caching at all) works in this case but it's also really bad so we shouldn't fall back to that. IIRC there are couple arrays with the elements (primary[parent] and secondary[child] the ones that depend on a primary) so the way out here is to recalculate the secondary elements more aggressively when a primary (parent) element is changed.
But maybe a missing trigger either on the input type-"radio"
or the select
element [debug this starting from this...]
Labels |
Added:
J4 Issue
|
Status | New | ⇒ | Discussion |
Category | ⇒ | JavaScript |
It doesn't seem to matter if the radio has the btn-group-yesno class or not. Switching to list field type works.
Status | Discussion | ⇒ | Confirmed |
Build | master | ⇒ | 4.0-dev |
Status | Confirmed | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-06-26 15:11:56 |
Closed_By | ⇒ | Quy |
Are you getting any errors on your browser console?