/**
 *
 * Build a div structure like this:
 
        <div class="form-group">
            <label for="inputAccount" class="col-lg-2 control-label">* 帳號</label>
            <div class="col-lg-10">
                <input id="inputAccount" type="text" name="account" placeholder="ariel123" readoly="" autocomplete="off" class="form-control">
            </div>
        </div>
 */
 public function build()
 {
     $wrapper = new Div(array('class' => $this->wrapperClass));
     $widget = $this->column->createWidget(null, $this->widgetAttributes);
     $widget->addClass('form-control');
     $widgetId = $widget->getSerialId();
     $wrapper->addClass($widget->convertClassToCssClassName());
     /*
     if ( $widget instanceof CheckboxInput ) {
         $label = $this->column->createLabelWidget();
         $label->prepend($widget);
         $wrapper->append($label);
     */
     if ($widget instanceof HiddenInput) {
         // $wrapper->append( $widget );
         return $widget;
     } else {
         $inputDiv = new Div(array('class' => $this->inputWrapperClass));
         $inputDiv->append($widget);
         $label = $this->column->createLabelWidget();
         $label->setAttributes(array('class' => $this->labelClass, 'for' => $widgetId));
         $wrapper->append($label);
         $wrapper->append($inputDiv);
         if ($this->column->hint) {
             $hintEl = new Span(array('class' => $this->hintClass));
             $hintEl->append($this->column->hint);
             $inputDiv->append($hintEl);
         }
     }
     return $wrapper;
 }
Exemple #2
0
 /**
 *
 * Build a div structure like this:
 
        <div class="v-field">
            <div class="label">{% trans 'Role' %}</div>
            <div class="input">
                <select name="role">
                    <option value="user">User</option>
                    <option value="admin">Admin</option>
                </select>
            </div>
        </div>
 */
 public function build()
 {
     $wrapper = new Div(array('class' => $this->wrapperClass));
     $widget = $this->column->createWidget(null, $this->widgetAttributes);
     $wrapper->addClass($widget->convertClassToCssClassName());
     if ($widget instanceof CheckboxInput) {
         $label = $this->column->createLabelWidget();
         $label->prepend($widget);
         $wrapper->append($label);
     } elseif ($widget instanceof HiddenInput) {
         $wrapper->append($widget);
     } else {
         $labelDiv = new Div(array('class' => $this->labelClass));
         $inputDiv = new Div(array('class' => $this->inputClass));
         $inputDiv->append($widget);
         $label = $this->column->createLabelWidget();
         $labelDiv->append($label);
         $wrapper->append($labelDiv);
         $wrapper->append($inputDiv);
         if ($this->column->hint) {
             $hintEl = new Span(array('class' => $this->hintClass));
             $hintEl->append($this->column->hint);
             $wrapper->append($hintEl);
         }
     }
     return $wrapper;
 }