What is the best way to group form elements?

bernhard
Member | 47
+
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/…ms/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!

bernhard
Member | 47
+
0
-

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

tpr
Member | 55
+
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"'));
?>