What is the best way to group form elements?

about a month ago

bernhard
Member | 6
+
0
-

Hello,

I've really tried to manage this for several hours today but failed. I want to group some fields of my form so that I can hide/unhide this block via JavaScript.

[] Different Shipping Address
- Forename
- Surname
- ZIP

I'd like to group those 3 fields into one wrapper. Or would you add a class to each of these fields?

https://doc.nette.org/…rm-rendering#… states that I can group fields, but I end up with <fieldset> and it seems that I cannot give this fieldset a name or a custom class?

Thank you for your help!

about a month ago

bernhard
Member | 6
+
0
-

I've ended up targeting one single input and hiding the closest() fieldset via jQuery…

about a month ago

tpr
Member | 56
+
0
-

You can set the html of agroup like this:

<?php
$form->addGroup('general')
    ->setOption('container', Html::el('div id="general-data" class="form-block-2"'));
?>