Exemplo n.º 1
0
 public function renderElement($element)
 {
     if (is_string($element)) {
         $e = $this->form->getElement($element);
     } else {
         $e = $element;
     }
     $type = $e->getType();
     $atts = $e->getAttributes();
     $atts['class'] = array_get($atts, 'class') . ' ' . 'form-control';
     $render = [];
     switch ($type) {
         case 'text':
         case 'textarea':
         case 'password':
         case 'hidden':
             $render[] = Form::label($e->getName(), $e->getLabel());
             $render[] = Form::$type($e->getName(), $e->getValue(), $atts);
             break;
         case 'checkbox':
         case 'radio':
             break;
         case 'select':
             $render[] = Form::label($e->getName(), $e->getLabel());
             $render[] = Form::select($e->getName(), (array) $e->getAttribute('options'), $e->getValue(), array_except($atts, ['options']));
             break;
         case 'submit':
             $render[] = Form::submit($e->getLabel());
             break;
     }
     if ($errors = $e->getMeta('errors')) {
         $render[] = '<p class="text-danger">' . implode('<br />', $errors) . '</p>';
     }
     return implode("\n", $render);
 }
Exemplo n.º 2
0
 private static function prv_getLabel($name, $label, $isRequired)
 {
     $labelRequired = $isRequired == true ? ' required' : '';
     return Form::label($name, $label, array('class' => 'control-label col-lg-2 col-sm-4' . $labelRequired));
 }
Exemplo n.º 3
0
Arquivo: Kuku.php Projeto: sukohi/kuku
 public function label($name, $value = null, $options = array())
 {
     $tag = Form::label($name, self::REPLACEMENT, $options);
     return $this->replace($value, $tag);
 }
Exemplo n.º 4
0
 public function label($attributes = array())
 {
     if ($this->required) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = '';
         }
         $attributes['class'] .= ' required';
     }
     return Form::label($this->name, $this->label, $attributes);
 }
Exemplo n.º 5
0
 /**
  * Builds the label html
  *
  * @param  string  $name The name of the html field
  * @param  string  $label The label name
  * @return string
  */
 private function buildLabel($name, $label = '')
 {
     $out = '';
     $class = 'col-sm-2 control-label';
     if (!empty($label)) {
         if ($this->getOption('requiredLabel') && substr($label, -strlen($this->getOption('requiredLabel'))) == $this->getOption('requiredLabel')) {
             $label = $this->getOption('requiredPrefix') . str_replace($this->getOption('requiredLabel'), '', $label) . $this->getOption('requiredSuffix');
             $class .= ' ' . $this->getOption('requiredClass');
         }
         $name = $this->getOption('idPrefix') . $name;
         $out .= Form::label($name, $label, array('class' => $class));
     } else {
         // blank label that still has a for
         $out .= Form::label($name, '&nbsp;', array('class' => $class));
     }
     return $out;
 }