How to render inputs of a form in line?

asinkan
Member | 38
+
0
-

Hello,

I have read manual about rendering of the forms.

I have a multiplier form:

protected function createComponentShopForm()
{
    return new Multiplier(function ($dayNumber) {


        $form = new Nette\Application\UI\Form;
        $form->addText('one', '');
        $form->addText('two', '');
        $form->addText('tree', '');

        $form->addSubmit('send', 'Add to cart')
        ->onClick[] = [$this, 'dayFormSucceeded'];


        $form->addHidden('itemId', $dayNumber);


        return $form;
    });
}

I added some render at the end:

         ...
        $form->addHidden('itemId', $dayNumber);

        $renderer = $form->getRenderer();
		$renderer->wrappers['controls']['container'] = 'td';
		$renderer->wrappers['pair']['container'] = 'td';
		$renderer->wrappers['label']['container'] ='td';
		$renderer->wrappers['control']['container'] = 'td';

        return $form;
    });
}

I expected that all text inputs will be in one row, but it did not happened. Only last input and submit button are in the row.

How to render it?

Thank you

asinkan
Member | 38
+
0
-

OK, I made it on my own :-)

Latte is:

<?php
<table id="attandanceTable">
 <tr>
       <td></td>
       <td colspan = "2"> Plán </td>
       <td colspan = "2"> Skutečnost </td>
 </tr>

 <tr>
      <td> Datum </td>
      <td> Příchod </td>
      <td> Odchod </td>
      <td> Příchod </td>
      <td> Odchod </td>
      <td> Započtená doba </td>
      <td> Pozdní omluva</td>
      <td> Řádná omluva </td>
 </tr>



{foreach $days as $day}
    {control dayForm-$day}
{/foreach}

</table>
?>

And render is

<?php
 $renderer = $form->getRenderer();
		$renderer->wrappers['controls']['container'] = 'tr';
		$renderer->wrappers['pair']['container'] = 'td';
		$renderer->wrappers['label']['container'] = null;
		$renderer->wrappers['control']['container'] = null;
?>

Of coarse without that <?php ?> shit

Last edited by asinkan (2018-02-01 01:41)

Faideark
Member | 1
+
0
-

thanks for updates but can you be a bit more detailed? would really appreciate some details, can I PM you in case i will need some help?