Exemple #1
0
 /**
  * @param  callable $primaryToString
  * @return Form
  */
 public function addGroupActionCheckboxes(callable $primaryToString)
 {
     if ($this->lazyCreateContainer('actions', 'records', $records)) {
         $i = 0;
         foreach ($this->getParent()->getData() as $record) {
             $primary = $primaryToString($record);
             $records[$primary] = $checkbox = new Checkbox();
             if ($i++ === 0) {
                 $checkbox->addRule(__CLASS__ . '::validateCheckedCount', 'Choose at least one record.');
             }
         }
     }
     foreach ($this['actions']['buttons']->getComponents() as $button) {
         $button->setValidationScope([$this['actions']['records']]);
     }
     return $this;
 }