How to create a form for each line of a query result
Notice: This thread is very old.
- netteman
- Member | 125
Hi
I'd like to have a form for editing each database line I “echo” in a
template by {foreach}.
I know I can do it by creating the html code manually but it seems a bit
clumsy.
Can I use createComponentDatabaselineForm or something similar to create the
multiple forms for me?
Thanks :)
Last edited by netteman (2016-08-17 20:22)
- Oli
- Member | 1215
There is 2 ways how to do it.
- Use Multiplier (in czech)
protected function createComponentShopForm()
{
return new Multiplier(function ($itemId) {
$form = new Nette\Application\UI\Form;
$form->addText('count', 'Počet zboží:')
->addRule($form::FILLED)
->addRule($form::INTEGER);
$form->addHidden('itemId', $itemId);
$form->addSubmit('send', 'Přidat do košíku');
return $form;
});
}
{foreach $items as $item}
<h2>{$item->title}</h2>
{$item->description}
{control shopForm-$item->id}
{/foreach}
- use Kdyby/Replicator
- dkorpar
- Member | 135
Maybe you want to use some datagrid with inline editing?
I'm using this one: http://ublaboo.org/datagrid/