Example #1
0
 /**
  * @param $renderApi
  * @param $unit
  * @return IOptionProvider
  */
 public function getListOptions($renderApi, $unit)
 {
     $options = preg_split('/\\n/', $renderApi->getFormValue($unit, 'listFieldOptions'));
     foreach ($options as $option) {
         $checked = false;
         if (preg_match('/\\*$/', $option)) {
             $checked = true;
             $option = preg_replace('/\\*$/', '', $option);
         }
         $optionObj = new \Option();
         $optionObj->setName($option);
         $optionObj->setValue($option);
         $optionObj->setChecked($checked);
         $this->optionProvider->addOption($optionObj);
     }
     return $this->optionProvider;
 }
Example #2
0
 /**
  * Creates an option and adds it to the receiver
  * 
  * @param String $value
  * @param String $label
  * @param (boolean) $checked
  * @param (String) $id
  */
 public function createOption($value, $label, $checked = false, $id = null)
 {
     // by incoming request
     $val = $this->getRequestValue();
     if ($val != null && $val == $value) {
         $checked = true;
     } else {
         if ($val != null && $val != $value) {
             $checked = false;
         }
     }
     $option = new Option();
     $option->setValue($value);
     $option->setLabel($label);
     $option->setChecked($checked);
     if (!is_null($id)) {
         $option->setId($id);
     }
     $this->options[] = $option;
     return $option;
 }