コード例 #1
0
 /**
  * @since  2014-09-17
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     $value = $input->getValue() === null ? $input->getDefaultValue() : $input->getValue();
     $inputName = $input->getName() === null ? $input->getId() : $input->getName();
     $itemWrapperOptions = isset($options['itemWrapperOptions']) ? $options['itemWrapperOptions'] : array();
     $baseItemAttributes = isset($options['itemAttributes']) ? $options['itemAttributes'] : array();
     ob_start();
     foreach ($input->getChoices() as $key => $label) {
         $itemAttributes = array('value' => $key, 'type' => 'radio', 'name' => $inputName);
         if ($key == $value) {
             $itemAttributes['checked'] = 'true';
         }
         //if
         echo h::tag('label', array_merge($itemWrapperOptions, array('content' => h::tag('input', array('attributes' => array_merge($baseItemAttributes, $itemAttributes), 'appendContent' => " {$label}", 'shortClosing' => true)), 'rawContent' => true)));
     }
     //foreach
     $radioListCode = ob_get_contents();
     ob_end_clean();
     $attributes = array('id' => $input->getId());
     if (isset($options['attributes'])) {
         $attributes = array_merge($attributes, $options['attributes']);
     }
     //if
     return h::tag('div', array('attributes' => $attributes, 'content' => $radioListCode, 'rawContent' => true));
 }
コード例 #2
0
 /**
  * @since  2014-09-17
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     $value = $input->getValue() === null ? $input->getDefaultValue() : $input->getValue();
     ob_start();
     foreach ($input->getChoices() as $key => $label) {
         $optionAttributes = array('value' => $key);
         if ($key == $value) {
             $optionAttributes['selected'] = 'true';
         }
         //if
         echo h::tag('option', array('attributes' => $optionAttributes, 'content' => $label));
     }
     //foreach
     $optionsCode = ob_get_contents();
     ob_end_clean();
     $attributes = array('id' => $input->getId(), 'name' => $input->getId());
     if ($input->getMultipleValues() === true) {
         $attributes['multiple'] = 'true';
         $attributes['name'] .= '[]';
     }
     //if
     if (isset($options['attributes'])) {
         $attributes = array_merge($attributes, $options['attributes']);
     }
     //if
     return h::tag('select', array('attributes' => $attributes, 'content' => $optionsCode, 'rawContent' => true));
 }
コード例 #3
0
 /**
  * @since  2014-05-09
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     $attributes = array('id' => $input->getId(), 'name' => $input->getName() === null ? $input->getId() : $input->getName(), 'value' => $input->getValue() === null ? $input->getDefaultValue() : $input->getValue());
     if ($input->getMultipleValues() === true) {
         $attributes['name'] .= '[]';
     }
     //if
     if (isset($options['attributes'])) {
         $attributes = array_merge($attributes, $options['attributes']);
     }
     //if
     return h::tag('input', array('attributes' => $attributes, 'shortClosing' => true));
 }
コード例 #4
0
 /**
  * @since  2014-09-20
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     if (!isset($options['attributes'])) {
         $options['attributes'] = array();
     }
     //if
     $value = $input->getValue();
     if ($value !== null && $value == $input->getDefaultValue()) {
         $options['attributes']['checked'] = 'true';
     }
     //if
     $options['attributes']['type'] = 'checkbox';
     return parent::format($input, $options);
 }