Ejemplo n.º 1
0
 /**
  * Checkbox
  *
  * @param $name
  * @param $value
  * @param string $checkValue
  * @param array $htmlOptions
  * @return Checkbox
  */
 public function checkbox($name, $value, $checkValue = "", $htmlOptions = [])
 {
     $cb = new Checkbox($name, $value, $htmlOptions);
     $cb->setExpectValue($checkValue);
     return $cb;
 }
Ejemplo n.º 2
0
 private function _propertyForm(\Terms $term, $taxonomy)
 {
     Plugin::applyFilters('term_property_form_' . $taxonomy);
     $controls = [];
     $propertiesOpt = Content::getTermPropertiesOpt($taxonomy);
     //form control
     foreach ($propertiesOpt as $key => $setting) {
         if (!$term->isNew()) {
             $setting['value'] = \TermProperty::getTermPropertyValue($term->getId(), $key);
         } else {
             $setting['value'] = '';
         }
         $name = "term_prop[{$key}]";
         $html_options = $setting;
         unset($html_options['label']);
         unset($html_options['value']);
         unset($html_options['control']);
         unset($html_options['options']);
         $controls[$key] = ['label' => isset($setting['label']) ? $setting['label'] : ''];
         switch ($setting['control']) {
             case 'input':
                 $object = new Input($name, $setting['value'], $html_options);
                 $object->setType($setting['type']);
                 unset($html_options['type']);
                 $controls[$key]['controlObject'] = $object;
                 break;
             case 'textarea':
                 $controls[$key]['controlObject'] = new TextArea($name, $setting['value'], $html_options);
                 break;
             case 'select':
                 $object = new SelectOption($name, $setting['value'], $html_options);
                 foreach (@$setting['options'] as $opt) {
                     $object->addOption($opt['label'], $opt['value'], @$opt['htmlOption']);
                 }
                 $controls[$key]['controlObject'] = $object;
                 break;
             case 'checkbox':
                 $object = new Checkbox($name, $setting['value'], $html_options);
                 $object->setExpectValue($setting['default']);
                 $controls[$key]['controlObject'] = $object;
                 break;
             case 'radio':
                 unset($html_options['options']);
                 $object = new RadioButton($name, $setting['value']);
                 foreach (@$setting['options'] as $opt) {
                     $object->add($opt['value'], $opt['label'], @$opt['htmlOption'], @$opt['inputOption']);
                 }
                 $controls[$key]['controlObject'] = $object;
                 break;
         }
     }
     return $controls;
 }
Ejemplo n.º 3
0
 /**
  * @param array $config
  * @param \Setting[] $setOms
  * @return mixed
  */
 private static function _getFormInput($config, $setOms)
 {
     foreach ($config as &$group) {
         foreach ($group['settings'] as $key => $setting) {
             if (isset($setOms[$key]) && $setting['control'] != 'checkbox') {
                 $group['settings'][$key]['value'] = $setOms[$key]->getSettingValue();
             }
             if (!isset($group['settings'][$key]['value'])) {
                 $group['settings'][$key]['value'] = null;
             }
             //get form control object
             $name = "setting[{$key}]";
             $html_options = $setting;
             unset($html_options['label']);
             unset($html_options['value']);
             unset($html_options['control']);
             switch ($setting['control']) {
                 case 'input':
                     $object = new Input($name, $group['settings'][$key]['value'], $html_options);
                     $object->setType($setting['type']);
                     unset($html_options['type']);
                     $group['settings'][$key]['controlObject'] = $object;
                     break;
                 case 'textarea':
                     $group['settings'][$key]['controlObject'] = new TextArea($name, $group['settings'][$key]['value'], $html_options);
                     break;
                 case 'selectOption':
                     $object = new SelectOption($name, $group['settings'][$key]['value'], $html_options);
                     foreach (@$setting['options'] as $opt) {
                         $object->addOption($opt['label'], $opt['value'], @$opt['htmlOption']);
                     }
                     $group['settings'][$key]['controlObject'] = $object;
                     break;
                 case 'checkbox':
                     $checkedValue = isset($setOms[$key]) ? $setOms[$key]->getSettingValue() : '';
                     $object = new Checkbox($name, $group['settings'][$key]['value'], $html_options);
                     $object->setExpectValue($checkedValue);
                     $group['settings'][$key]['controlObject'] = $object;
                     break;
                 case 'radio':
                     unset($html_options['options']);
                     $object = new RadioButton($name, $group['settings'][$key]['value']);
                     foreach (@$setting['options'] as $opt) {
                         $object->add($opt['value'], $opt['label'], @$opt['htmlOption'], @$opt['inputOption']);
                     }
                     $group['settings'][$key]['controlObject'] = $object;
                     break;
             }
         }
     }
     return $config;
 }