Created
March 30, 2010 17:02
-
-
Save jsmitka/349303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{block #content} | |
{? $form = $component['form']} | |
{widget form 'begin'} | |
{widget form 'errors'} | |
<table> | |
<thead> | |
<tr> | |
<th> </th> | |
<th>Jméno</th> | |
<th>URL</th> | |
<th>Popis</th> | |
</tr> | |
</thead> | |
<tbody> | |
{foreach $items as $item} | |
<tr> | |
<td>{$form['items'][(string) $item->id]->getControl()}</td> | |
<td>{$item->name}</td> | |
<td>{$item->url}</td> | |
<td>{$item->description}</td> | |
</tr> | |
{/foreach} | |
</tbody> | |
</table> | |
{widget form 'body'} | |
{widget form 'end'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestPresenter extends BasePresenter | |
{ | |
/** | |
* @var DibiResult | |
*/ | |
protected $items; | |
public function actionDefault() | |
{ | |
$this->items = $model->getServicestate(); | |
} | |
public function renderDefault() | |
{ | |
$this->template->items = $this->items; | |
} | |
public function createComponentForm() | |
{ | |
$form = new AppForm(); | |
$items = $form->addContainer('items'); | |
foreach ($this->items as $item) { | |
$items->addCheckbox((string) $item->id, ''); | |
} | |
$form->addSubmit('approve', 'Schválit'); | |
$form->addSubmit('delete', 'Smazat'); | |
$form->onSubmit[] = array($this, 'form_Submit'); | |
return $form; | |
} | |
public function form_Submit(Form $form) | |
{ | |
$values = $form->getValues(); | |
$items = array(); | |
foreach ($values['items'] as $id => $value) | |
if ($value) $items[] = $id; | |
// pole $items obsahuje seznam IDček | |
if ($form['approve']->isSubmittedBy()) { | |
// ... | |
} elseif ($form['delete']->isSubmittedBy()) { | |
// ... | |
} | |
$this->redirect('this'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment