예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct($options)
 {
     if (!isset($options['validator'])) {
         $this->setValidator(new TextValidator());
     }
     if (isset($options['value'])) {
         $this->data = $options['value'];
         unset($options['value']);
     }
     parent::__construct($options);
 }
예제 #2
0
    /**
     * {@inheritdoc}
     */
    public function renderField(FormField $field)
    {
        $field->addClass('form-control');
        $tags = $field->getTags();
        $groupClass = 'form-group';
        if (isset($tags['disabled']) && $tags['disabled']) {
            $groupClass .= ' hide';
        }
        if (!$field->isValid()) {
            $groupClass .= ' has-error';
        }
        if ($field->isRequired()) {
            $groupClass .= ' has-required';
        }
        $html = '<div class="' . $groupClass . '">
			<label class="col-sm-3 control-label" for="' . $field->getId() . '">' . $field->getLabel() . '</label>
			<div class="col-sm-6">
			' . $field->componentRender() . '
			' . (!$field->isValid() ? '<label for="name" class="error">' . $field->getError() . '</label>' : '') . '
			</div>
		</div>';
        return $html;
    }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function renderField(FormField $field)
 {
     $html = $field->render();
     return $html;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function __construct($options)
 {
     parent::__construct($options);
 }
예제 #5
0
 /**
  * Add form field
  *
  * @param \Arbor\Component\Form\FormField $field
  * @since 0.15.0
  */
 public function addField(FormField $field)
 {
     $this->fields[] = $field;
     if ($field->getName() == null) {
         $field->setName('name_' . count($this->fields));
     }
     if ($field->getId() == null) {
         $field->setId('id_' . count($this->fields));
     }
     if ($field instanceof FileField) {
         $this->formTags['enctype'] = 'multipart/form-data';
     }
 }