예제 #1
0
파일: Field.php 프로젝트: jivoo/jivoo
 /**
  * Close this field.
  * @return Field|null This field or null if already closed.
  */
 public function end()
 {
     if (!$this->open) {
         return null;
     }
     $this->open = false;
     $this->Form->end();
     if ($this->prop('defaultContent') !== 'none') {
         $label = null;
         if ($this->hasProp('label')) {
             $label = $this['label'];
             if (is_array($label)) {
                 $this->prepend($this->label(null, $label));
             } else {
                 if (!empty($label)) {
                     $this->prepend($this->label($label));
                 }
             }
         } else {
             $this->prepend($this->label());
         }
         if ($this->prop('input') !== '') {
             if ($this->hasProp('type')) {
                 $type = $this['type'];
                 $this->append($this->Form->{$type}($this->field, $this->prop('input')));
             } else {
                 $this->append($this->Form->input($this->field, $this->prop('input')));
             }
         }
         $helpDiv = new Html('div');
         $helpDiv->addClass('help');
         if ($this->hasProp('help')) {
             $helpDiv->attr($this['help']);
         }
         if ($this->Form->isInvalid($this->field)) {
             $helpDiv->html($this->Form->error($this->field));
             $this->append($helpDiv->toString());
         } else {
             if ($this->hasProp('description')) {
                 $helpDiv->html($this['description']);
                 $this->append($helpDiv->toString());
             }
         }
     }
     return $this;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function field(FormHelper $Form, $field, $options = array())
 {
     return $Form->textarea($field, $options);
 }