Esempio n. 1
0
 public static function Factory($name, $checkboxList, $label, $required = false, $checked = null)
 {
     $fieldSet = FieldSet::Factory($name . '_list', $label);
     if (is_array($checkboxList) && !empty($checkboxList)) {
         $i = 0;
         foreach ($checkboxList as $value => $label) {
             $id = $name . ++$i;
             $fieldSet->addElement(InputCheckbox::Factory($name, $value, $label, $id));
         }
     }
     return $fieldSet;
 }
Esempio n. 2
0
 /**
  * return a InputCheckbox for a model property
  *
  * @see InputCheckbox
  * @return InputCheckbox
  * @author Justin Palmer
  **/
 public function check_box($property, $options = '', $checked_value = '1', $unchecked_value = '0')
 {
     $options = $this->checkForErrors($property, $options);
     $check = new InputCheckbox($this->getElementName($property), $options, $checked_value, $unchecked_value);
     $check->setChecked($this->getValue($property));
     return $check;
 }