public function renderElement($element) { if (is_string($element)) { $e = $this->form->getElement($element); } else { $e = $element; } $type = $e->getType(); $atts = $e->getAttributes(); $atts['class'] = array_get($atts, 'class') . ' ' . 'form-control'; $render = []; switch ($type) { case 'text': case 'textarea': case 'password': case 'hidden': $render[] = Form::label($e->getName(), $e->getLabel()); $render[] = Form::$type($e->getName(), $e->getValue(), $atts); break; case 'checkbox': case 'radio': break; case 'select': $render[] = Form::label($e->getName(), $e->getLabel()); $render[] = Form::select($e->getName(), (array) $e->getAttribute('options'), $e->getValue(), array_except($atts, ['options'])); break; case 'submit': $render[] = Form::submit($e->getLabel()); break; } if ($errors = $e->getMeta('errors')) { $render[] = '<p class="text-danger">' . implode('<br />', $errors) . '</p>'; } return implode("\n", $render); }
public function build() { $output = ""; $this->attributes["class"] = "btn btn-default"; 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)); } break; case "create": case "modify": $output = Form::submit($this->label, $this->attributes); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
/** * @param string $name * @param string $position * @param array $options * * @return $this */ public function submit($name, $position = "BL", $options = array()) { $options = array_merge(array("class" => "btn btn-primary"), $options); $this->button_container[$position][] = Form::submit($name, $options); return $this; }
/** * return a form with a nested action button * @param $url * @param $method * @param $name * @param string $position * @param array $attributes * @return $this */ public function formButton($url, $method, $name, $position = "BL", $attributes = array()) { $attributes = array_merge(array("class" => "btn btn-default"), $attributes); $this->button_container[$position][] = Form::open(array('url' => $url, 'method' => $method)) . Form::submit($name, $attributes) . Form::close(); return $this; }