Skip to content
Permalink
Browse files

DefaultFormRenderer: options 'class' & 'id' are used for 'control' pa…

…rt when 'pair' part is empty
  • Loading branch information
dg committed Mar 25, 2020
1 parent ee132bf commit c8c275d7f6da214512749d31b255e11dc181c2c1
@@ -431,6 +431,10 @@ public function renderControl(Nette\Forms\IControl $control): Html
if ($this->counter % 2) {
$body->class($this->getValue('control .odd'), true);
}
if (!$this->getWrapper('pair container')->getName()) {
$body->class($control->getOption('class'), true);
$body->id = $control->getOption('id');
}

$description = $control->getOption('description');
if ($description instanceof IHtmlString) {
@@ -5,7 +5,7 @@
<p>We value your privacy and we ensure that the information you give to us will not be shared to other entities.</p>

<table>
<tr class="required">
<tr class="required myclass" id="myid">
<th><label for="frm-name" class="required">Your name:</label></th>

<td><input type="text" name="name" id="frm-name" required data-nette-rules='[{"op":":filled","msg":"Enter your name"}]' value="John Doe" class="text"></td>
@@ -43,7 +43,9 @@ $form->addGroup('Personal data')
->setOption('id', 'test-group-id-set-via-option');

$form->addText('name', 'Your name:')
->addRule(Form::FILLED, 'Enter your name');
->addRule(Form::FILLED, 'Enter your name')
->setOption('class', 'myclass')
->setOption('id', 'myid');

$form->addInteger('age', 'Your age:')
->addRule(Form::FILLED, 'Enter your age')
@@ -7,7 +7,7 @@

<dt><label for="frm-name" class="required">Your name:</label></dt>

<dd><input type="text" name="name" id="frm-name" required data-nette-rules='[{"op":":filled","msg":"Enter your name"}]' value="John Doe" class="text"> •</dd>
<dd class="myclass" id="myid"><input type="text" name="name" id="frm-name" required data-nette-rules='[{"op":":filled","msg":"Enter your name"}]' value="John Doe" class="text"> •</dd>



@@ -55,7 +55,9 @@ $renderer->wrappers['control']['requiredsuffix'] = " \u{2022}";

$form->addGroup('Personal data');
$form->addText('name', 'Your name')
->addRule(Form::FILLED, 'Enter your name');
->addRule(Form::FILLED, 'Enter your name')
->setOption('class', 'myclass')
->setOption('id', 'myid');

$form->addText('age', 'Your age')
->addRule(Form::FILLED, 'Enter your age')

0 comments on commit c8c275d

Please sign in to comment.
You can’t perform that action at this time.