Skip to content

Commit

Permalink
Single global action render as hidden field
Browse files Browse the repository at this point in the history
  • Loading branch information
Miloslav Hůla committed May 25, 2018
1 parent 7844c57 commit f806dd8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,18 @@ public function createComponentForm()

if ($this->globalActions) {
$actions = array_map(function($row) { return $row[0]; }, $this->globalActions);
$form['actions'] = new Container();
$form['actions']->addSelect('action', 'Action', $actions)
->setPrompt('- select action -');
$form['actions'] = new Container;
$form['actions']->addCheckboxList('items', '', []);
$form['actions']->addSubmit('process', 'Do')->setValidationScope(false);

if (count($actions) === 1) {
$form['actions']->addHidden('action', key($actions));
$form['actions']->addSubmit('process', current($actions))->setValidationScope(false);

} else {
$form['actions']->addSelect('action', 'Action', $actions)
->setPrompt('- select action -');
$form['actions']->addSubmit('process', 'Do')->setValidationScope(false);
}
}

if ($this->translator) {
Expand Down

0 comments on commit f806dd8

Please sign in to comment.