Example #1
0
 function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->checked ? $this->checked_output : $this->unchecked_output;
             }
             break;
         case "create":
         case "modify":
             $output = Form::checkbox($this->name, $this->checked_value, $this->checked) . $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #2
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->checked ? $this->checked_output : $this->unchecked_output;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             //dd($this->checked);
             $output = Form::checkbox($this->name, $this->checked_value, $this->checked, $this->attributes) . $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #3
0
 /**
  * Make field HTML from field array
  *
  * @param  array  $field
  * @return string
  */
 private function makeField($field)
 {
     $output = '';
     //combine additional input attributes
     $input_attributes = array('class' => $field['input-class']);
     $input_attributes = array_merge($input_attributes, $field['input-attributes']);
     //
     //TEXT
     if ($field['type'] == "text") {
         $output .= Form::text($field['name'], $field['value'], $input_attributes);
     }
     //TEXTAREA
     if ($field['type'] == "textarea") {
         $output .= Form::textarea($field['name'], $field['value'], $input_attributes);
     }
     //PASSWORD
     if ($field['type'] == "password") {
         $output .= Form::password($field['name'], $field['value'], $input_attributes);
     }
     //SELECT
     if ($field['type'] == "select") {
         $output .= Form::select($field['name'], $field['options'], $field['value'], $input_attributes);
     }
     //CHECKBOXES
     if ($field['type'] == "checkbox") {
         foreach ($field['options'] as $option_key => $option_value) {
             $output .= '<label class="checkbox">';
             $checked = null;
             if (is_array($field['value']) && in_array($option_key, $field['value'])) {
                 $checked = true;
             }
             $output .= Form::checkbox($field['name'], $option_key, $checked);
             $output .= $option_value;
             $output .= '</label>';
         }
     }
     //RADIO
     if ($field['type'] == "radio") {
         foreach ($field['options'] as $option_key => $option_value) {
             $output .= '<label class="radio">';
             $checked = false;
             if ($option_key == $field['value']) {
                 $checked = true;
             }
             $output .= Form::radio($field['name'], $option_key, $checked);
             $output .= $option_value;
             $output .= '</label>';
         }
     }
     //FILE
     if ($field['type'] == "file") {
         $output .= Form::file($field['name'], $input_attributes);
     }
     //return
     return $output;
 }
 public function build()
 {
     $output = "";
     if (!isset($this->style)) {
         $this->style = "margin:0 2px 0 0; vertical-align: middle";
     }
     unset($this->attributes['id']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             //dd($this->options, $this->values);
             foreach ($this->options as $val => $label) {
                 $this->checked = in_array($val, $this->values);
                 //echo ((int)$this->checked)."<br />";
                 $output .= sprintf($this->format, Form::checkbox($this->name . '[]', $val, $this->checked) . $label) . $this->separator;
             }
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #5
0
 public function build()
 {
     $this->path = $this->parseString($this->path);
     $this->web_path = $this->parseString($this->web_path);
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->old_value) {
                 $output .= '<div class="clearfix">';
                 $output .= link_to($this->web_path . $this->value, $this->value) . "&nbsp;";
                 $output .= Form::checkbox($this->name . '_remove', 1, (bool) Input::get($this->name . '_remove')) . " " . trans('rapyd::rapyd.delete') . " <br/>\n";
                 $output .= '</div>';
             }
             $output .= Form::file($this->name, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #6
0
});
Form::macro('selectField', function ($name, $label = null, $options, $value = null, $attributes = []) {
    $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = []) {
    $attributes = array_merge($attributes, ['multiple' => true]);
    $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = []) {
    $attributes = array_merge(['id' => 'id-field-' . $name], $attributes);
    $out = '<div class="checkbox';
    $out .= fieldError($name) . '">';
    $out .= '<label>';
    $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label;
    $out .= '</div>';
    return $out;
});
function fieldWrapper($name, $label, $element)
{
    $out = '<div class="form-group';
    $out .= fieldError($name) . '">';
    $out .= fieldLabel($name, $label);
    $out .= $element;
    $out .= fieldErrorMessage($name);
    $out .= '</div>';
    return $out;
}
function fieldError($field)
{
Example #7
0
 /**
  * Create a HTML checkbox input element.
  *
  * @param  string  $name
  * @param  string  $label
  * @param  string  $value
  * @param  bool    $checked
  * @param  array   $attributes
  * @return string
  */
 public function checkbox($name, $label = '', $value = '1', $checked = false, $attributes = array())
 {
     $checked = $this->calculateValue($name, $checked);
     $attributes = $this->setAttributes($name, $attributes, true);
     $field = Form::checkbox($name, $value, $checked, $attributes);
     return $this->buildWrapper($field, $name, $label, true);
 }