It looks like you're new here. If you want to get involved, click one of these buttons!
I've read this topic from 2015:
I'm on the develop branch.
With this config in a modules form_fields method:
$fields['workshop'] = [ 'type' => 'toggler', 'prefix' => 'toggle_workshop_', 'options' => ['yes' => 'yes', 'no' => 'no'], 'first_option' => 'Is this entry a workshop or not?', 'required' => true ]; $fields['workshop_details'] = [ 'display_label' => false, 'repeatable' => true, 'class' => 'toggle toggle_workshop_yes', 'type' => 'template', 'fields' => [ 'workshop_title' => , 'entries' => [ 'type' => 'template', 'fields' => [ 'time' => , 'title' => , 'content' => [ 'type' => 'textarea' ] ] ] ] ];
The workshop_details fields are always visible.
If I simplify it by removing the nested 'entries' template type - no change.
If I change the workshop_details field to a simple single text input it does toggle as expected.
You may need to add that class parameter to each of the fields instead:
Updated it to:
Resulted in all the fields being removed but not the surrounding template. I mean you can still see the grey boxes and "Remove" buttons and drag handles.
I see. The template field is actually not so much a field but a container of fields. There are a couple other options though. There is a
selectorparameter that you can use. The
contextparameter is the dom reference of the container element in which to find the specified class (default is
selectorparameter specifies what closest element it will look for to hide (default is the
tr). Additionally, there is a
templateparameter which you can specify view file path with the contents of something like this example which is custom HTML: