/**
  * @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));
 }
 /**
  * @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));
 }
Esempio n. 3
0
 /**
  * @since  2014-09-23
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     $formatter = $options['formatter'];
     $formatterName = $options['formatterName'];
     switch ($formatterName) {
         case 'radioListInput':
             $inputOptions = isset($options['inputOptions']) ? $options['inputOptions'] : array();
             $errorOptions = isset($options['errorOptions']) ? $options['errorOptions'] : array();
             if (!isset($options['attributes'])) {
                 $options['attributes'] = array();
             }
             //if
             $options['attributes'] = array_merge(array('class' => 'form-group'), $options['attributes']);
             ob_start();
             echo h::tag('label', array('content' => $input->getLabel(), 'rawContent' => true));
             echo $formatter->radioListInput($input, $options);
             echo $formatter->error($input, $errorOptions);
             $content = ob_get_contents();
             ob_end_clean();
             $attributes = array('class' => substr($formatterName, 0, -5));
             if (isset($options['attributes'])) {
                 $attributes = array_merge($attributes, $options['attributes']);
             }
             //if
             return h::tag('div', array('attributes' => $attributes, 'content' => $content, 'rawContent' => true)) . "\n";
             break;
         case 'checkboxInput':
         case 'radioInput':
             $inputOptions = isset($options['inputOptions']) ? $options['inputOptions'] : array();
             $errorOptions = isset($options['errorOptions']) ? $options['errorOptions'] : array();
             ob_start();
             echo h::tag('label', array('content' => call_user_func(array($formatter, $formatterName), $input, $inputOptions) . ' ' . $input->getLabel(), 'rawContent' => true));
             echo $formatter->error($input, $errorOptions);
             $content = ob_get_contents();
             ob_end_clean();
             $attributes = array('class' => substr($formatterName, 0, -5));
             if (isset($options['attributes'])) {
                 $attributes = array_merge($attributes, $options['attributes']);
             }
             //if
             return h::tag('div', array('attributes' => $attributes, 'content' => $content, 'rawContent' => true)) . "\n";
             break;
         default:
             if (!isset($options['attributes'])) {
                 $options['attributes'] = array();
             }
             //if
             $options['attributes'] = array_merge(array('class' => 'form-group'), $options['attributes']);
             return parent::format($input, $options);
             break;
     }
     //switch
 }
Esempio n. 4
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));
 }
 /**
  * @since  2014-09-23
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     $formatter = $options['formatter'];
     $formatterName = $options['formatterName'];
     $inputOptions = isset($options['inputOptions']) ? $options['inputOptions'] : array();
     $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : array();
     $errorOptions = isset($options['errorOptions']) ? $options['errorOptions'] : array();
     ob_start();
     echo $formatter->label($input, $labelOptions);
     echo call_user_func(array($formatter, $formatterName), $input, $inputOptions);
     echo $formatter->error($input, $errorOptions);
     $content = ob_get_contents();
     ob_end_clean();
     $attributes = array('class' => $input->getId());
     if (isset($options['attributes'])) {
         $attributes = array_merge($attributes, $options['attributes']);
     }
     //if
     return h::tag('div', array('attributes' => $attributes, 'content' => $content, 'rawContent' => true)) . "\n";
 }
 /**
  * @since  2014-05-09
  * @author Patrick Forget <*****@*****.**>
  */
 public function format(\Informant\Input\BaseElement $input, $options = array())
 {
     $messages = $this->getMessages($input);
     if (sizeof($messages) > 0) {
         $attributes = isset($options['attributes']) ? $options['attributes'] : array();
         $messageAttributes = isset($options['messageAttributes']) ? $options['messageAttributes'] : array();
         if (!isset($attributes['class'])) {
             $attributes['class'] = 'messages ' . $this->getMessageClass();
         }
         //if
         ob_start();
         foreach ($messages as $message) {
             echo html::tag('li', array('attributes' => $messageAttributes, 'content' => $message));
         }
         //foreach
         $code = html::tag('ul', array('attributes' => $attributes, 'content' => ob_get_contents(), 'rawContent' => true));
         ob_end_clean();
     } else {
         $code = '';
     }
     //if
     return $code;
 }