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 . " </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; }
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 . " </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; }
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 . " </div>"; break; case "create": case "modify": if ($this->old_value) { $output .= '<div class="clearfix">'; $output .= link_to($this->web_path . $this->value, $this->value) . " "; $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"; }
Form::macro('radioSwitch', function ($name, $values = null, $checked = null, $options = array()) { if (is_null($values)) { $values = [1 => transpine('helpers.yes'), 0 => transpine('helpers.no')]; $checked = is_null($checked) ? null : (int) $checked; } if (is_null($checked)) { $checked = array_keys($values)[0]; } $html = '<p class="field switch">'; foreach ($values as $value => $label) { $options['id'] = $name . $value . microtime(); $html .= Form::radio($name, $value, $checked === $value, $options); $labelClass = $value == 0 ? 'cb-disable' : 'cb-enable'; $labelClass .= $checked === $value ? ' selected' : ''; $html .= Form::label($options['id'], $label, ['class' => $labelClass]); } $html .= '</p>'; return $html; }); /** * Create a checkbox input field with forced zero value for unchecked. * * @param string $name * @param mixed $value * @param bool $checked * @param array $options * @return string */ Form::macro('checkboxForced', function ($name, $value = 1, $checked = null, $options = array()) { return Form::hidden($name, 0) . Form::checkbox($name, $value, $checked, $options); });