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"; }
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": $this->attributes['multiple'] = 'multiple'; $output .= \Form::select($this->name . '[]', $this->options, $this->values, $this->attributes); $output .= $this->extra_output; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
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 = ""; if (parent::build() === false) { return; } switch ($this->status) { case "show": $output = $this->value; $output = "<div class='help-block' style='background-color:" . $output . "'> </div>"; break; case "create": case "modify": Rapyd::css('colorpicker/css/bootstrap-colorpicker.min.css'); Rapyd::js('colorpicker/js/bootstrap-colorpicker.min.js'); $output = Form::text($this->name, $this->value, $this->attributes); $output .= Rapyd::script("\n \$('#" . $this->name . "').colorpicker({\n format: 'hex'\n });"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; $this->attributes["class"] = "form-control"; 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": Rapyd::js('packages/zofe/rapyd/assets/tinymce/tinymce.min.js'); $output = Form::textarea($this->db_name, $this->value, $this->attributes); $output .= Rapyd::script("\n tinymce.init({\n selector: 'textarea#" . $this->name . "',\n plugins: [\n 'advlist autolink link image lists charmap print preview hr anchor pagebreak',\n 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n 'save table contextmenu directionality emoticons template paste textcolor responsivefilemanager'\n ],\n toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | responsivefilemanager | print preview media fullpage | forecolor backcolor emoticons', \n image_advtab: true ,\n external_filemanager_path:'" . URL::to('/') . "/packages/filemanager/',\n filemanager_title:'Upload',\n });"); break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
function build() { $output = ""; if (!isset($this->style) and !isset($this->attributes['style'])) { $this->style = "width:290px;"; } unset($this->attributes['type'], $this->attributes['size']); 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": $output = \Form::select($this->name, $this->options, $this->value, $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 (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": Rapyd::js('redactor/jquery.browser.min.js'); Rapyd::js('redactor/redactor.min.js'); Rapyd::css('redactor/css/redactor.css'); $output = Form::textarea($this->name, $this->value, $this->attributes); Rapyd::script("\$('#" . $this->name . "').redactor();"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
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->description; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": foreach ($this->options as $val => $label) { $this->checked = (!is_null($this->value) and $this->value == $val); $output .= Form::radio($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; }
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; }
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 = ""; $this->attributes["class"] = "form-control"; 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": $output = Form::file($this->db_name, $this->attributes); break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $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 = '<div class="textarea_html_disabled"><pre>' . htmlspecialchars($this->value) . '</pre></div>'; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::textarea($this->name, $this->value, $this->attributes); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; unset($this->attributes['type']); if (parent::build() === false) { return; } switch ($this->status) { case "show": if (!isset($this->value)) { $value = $this->layout['null_label']; } else { $value = $this->isoDateToHuman($this->value); } $output = $value; $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": if ($this->value != "") { if (!$this->is_refill) { $this->value = $this->isoDateToHuman($this->value); } } Rapyd::css('datepicker/datepicker3.css'); Rapyd::js('datepicker/bootstrap-datepicker.js'); if ($this->language != "en") { Rapyd::js('datepicker/locales/bootstrap-datepicker.' . $this->language . '.js'); } unset($this->attributes['id']); //$this->attributes['class'] = "form-control"; $from = Form::text($this->name . '[]', @$this->values[0], $this->attributes); $to = Form::text($this->name . '[]', @$this->values[1], $this->attributes); $output = ' <div id="range_' . $this->name . '_container"> <div class="input-daterange"> <div class="input-group"> <div class="input-group-addon">≥</div> ' . $from . ' </div> <div class="input-group"> <div class="input-group-addon">≤</div> ' . $to . ' </div> </div> </div>'; Rapyd::pop_script(); Rapyd::script("\n \$('#range_{$this->name}_container .input-daterange').datepicker({\n format: '{$this->formatToDate()}',\n language: '{$this->language}',\n todayBtn: 'linked',\n autoclose: true\n });"); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = $output; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": break; case "create": case "modify": case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
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 prepareForm() { $form_attr = array('url' => $this->process_url, 'class' => "form-horizontal", 'role' => "form", 'method' => $this->method); $form_attr = array_merge($form_attr, $this->attributes); // See if we need a multipart form foreach ($this->fields as $field_obj) { if (in_array($field_obj->type, array('file', 'image'))) { $form_attr['files'] = 'true'; break; } } // Set the form open and close if ($this->status == 'show') { $this->open = '<div class="form">'; $this->close = '</div>'; } else { $this->open = Form::open($form_attr); $this->close = Form::hidden('save', 1) . Form::close(); if ($this->method == "GET") { $this->close = Form::hidden('search', 1) . Form::close(); } } if (isset($this->validator)) { $this->errors = $this->validator->messages(); $this->error .= implode('<br />', $this->errors->all()); } }
public function label($name, $value = null, $options = array()) { $tag = Form::label($name, self::REPLACEMENT, $options); return $this->replace($value, $tag); }
public static function token() { return Form::token(); }
public function label($attributes = array()) { if ($this->required) { if (!isset($attributes['class'])) { $attributes['class'] = ''; } $attributes['class'] .= ' required'; } return Form::label($this->name, $this->label, $attributes); }
protected function buildForm() { $data = get_object_vars($this); $data['buttons'] = $this->button_container; $form_attr = array('url' => $this->process_url, 'class' => "", 'role' => "form", 'method' => $this->method); // See if we need a multipart form foreach ($this->fields as $field_obj) { if ($field_obj->type == 'file') { $form_attr['files'] = 'true'; break; } } // Set the form open and close if ($this->status == 'show') { $data['form_begin'] = '<div class="form">'; $data['form_end'] = '</div>'; } else { $data['form_begin'] = Form::open($form_attr); $data['form_end'] = Form::hidden('save', 1) . Form::close(); if ($this->method == "GET") { $data['form_end'] = Form::hidden('search', 1) . Form::close(); } } if (isset($this->validator)) { $data['errors'] = $this->validator->messages(); } $data['message'] = $this->process_status == "success" ? $this->message : ''; $data['groups'] = $this->regroupFields($this->orderFields($this->fields)); return View::make($this->view, $data); }
public function build() { $output = ""; unset($this->attributes['type']); if (parent::build() === false) { return; } switch ($this->status) { case "show": if (!isset($this->value)) { $value = $this->layout['null_label']; } else { $value = $this->isodatetimeToHuman($this->value); } $output = $value; $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": if ($this->value != "") { if (!$this->is_refill) { $this->value = $this->isodatetimeToHuman($this->value); } } Rapyd::css('datetimepicker/datetimepicker3.css'); Rapyd::js('datetimepicker/bootstrap-datetimepicker.js'); if ($this->language != "en") { Rapyd::js('datetimepicker/locales/bootstrap-datetimepicker.' . $this->language . '.js'); } $output = Form::text($this->name, $this->value, $this->attributes); Rapyd::script("\n \$('#" . $this->name . "').datetimepicker({\n format: '{$this->formatTodatetime()}',\n language: '{$this->language}',\n todayBtn: 'linked',\n autoclose: true\n });"); break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = $output; }
/** * Generate the button * @return string dataview */ public function __toString() { $strTitle = ''; $strLabel = $this->mIcon . ' ' . $this->mLabel; $strPrefix = ''; $strSufix = ''; if ($this->mSmall) { $strTitle = ' title="' . $this->mLabel . '"'; $strLabel = $this->mIcon; } if ($this->mIsDeleteButton) { $strPrefix = Form::open(array('method' => 'delete', 'url' => $this->mDataUri, 'style' => 'display:inline!important;padding:0px;margin:0px')); $strSufix = Form::close(); $this->enableConfirmation(trans('forms.confirm.text_delete')); } if ($this->mConfirmation) { $dialogTitle = trans('forms.confirm.title'); $dialogMessage = $this->mConfirmationMessage; $dialogButtonOk = trans('forms.confirm.button_confirm'); $dialogButtonCancel = trans('forms.confirm.button_cancel'); $dialogAction = $this->mIsDeleteButton ? 'parentNode.submit()' : 'window.location.href=\'$this->mDataUri\''; $dialog = <<<EOD BootstrapDialog.show({ title:'{$dialogTitle}', message:'{$dialogMessage}', type:BootstrapDialog.TYPE_DEFAULT, buttons: [ {label:'{$dialogButtonCancel}', action:function(dialog){dialog.close();}}, {label:'{$dialogButtonOk}', cssClass:'btn-primary', action:function(dialog){ {$dialogAction}; dialog.close();}}, ] }); EOD; $this->mAttributes[] = 'onclick="' . trim($dialog) . '"'; $this->mDataUri = '#'; } return $strPrefix . '<a role="button" ' . 'href="' . $this->mDataUri . '" ' . 'class="' . implode(' ', $this->mClasses) . '" ' . 'style="' . implode(' ', $this->mStyles) . '" ' . implode(' ', $this->mAttributes) . $strTitle . '>' . $strLabel . '</a>' . $strSufix; }
/** * Update action url in model form to be protocal-relative. * @var str $model * @var array $attributes * * @return str */ public static function model($model, $attributes = array('url' => '/')) { return str_replace('http:', null, Form::model($model, $attributes)); }
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"; }
public function build() { $output = ""; Rapyd::css('packages/zofe/rapyd/assets/autocomplete/autocomplete.css'); Rapyd::js('packages/zofe/rapyd/assets/autocomplete/typeahead.bundle.min.js'); Rapyd::js('packages/zofe/rapyd/assets/template/handlebars.js'); unset($this->attributes['type']); if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if (!isset($this->value)) { $output = $this->layout['null_label']; } elseif ($this->value == "") { $output = ""; } else { $output = nl2br(htmlspecialchars($this->value)); if ($this->is_multiple) { $output = '<div class="textarea_disabled">' . $output . '</div>'; } } break; case "create": case "modify": if (Input::get("auto_" . $this->db_name)) { $autocomplete = Input::get("auto_" . $this->db_name); } elseif ($this->relation != null) { $name = $this->rel_field; $autocomplete = @$this->relation->get()->first()->{$name}; } elseif (count($this->local_options)) { $autocomplete = $this->description; } else { $autocomplete = $this->value; } $output = Form::text("auto_" . $this->name, $autocomplete, array_merge($this->attributes, array('id' => "auto_" . $this->name))) . "\n"; $output .= Form::hidden($this->name, $this->value, array('id' => $this->name)); if ($this->remote) { $script = <<<acp var blod_{$this->name} = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('auto_{$this->name}'), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: '{$this->remote}?q=%QUERY' }); blod_{$this->name}.initialize(); \$('#div_{$this->name} .typeahead').typeahead(null, { name: '{$this->name}', displayKey: '{$this->record_label}', highlight: true, minLength: {$this->min_chars}, source: blod_{$this->name}.ttAdapter(), templates: { suggestion: Handlebars.compile('{{{$this->record_label}}}') } }).on("typeahead:selected typeahead:autocompleted", function(e,data) { \$('#{$this->name}').val(data.{$this->record_id}); }); acp; $output .= Rapyd::script($script); } elseif (count($this->options)) { $options = json_encode($this->local_options); //options $script = <<<acp var {$this->name}_options = {$options}; var blod_{$this->name} = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), queryTokenizer: Bloodhound.tokenizers.whitespace, local: {$this->name}_options }); blod_{$this->name}.initialize(); \$('#div_{$this->name} .typeahead').typeahead({ hint: true, highlight: true, minLength: {$this->min_chars} }, { name: '{$this->name}', displayKey: 'value', source: blod_{$this->name}.ttAdapter() }).on("typeahead:selected typeahead:autocompleted", function(e,data) { \$('#{$this->name}').val(data.key); }); acp; $output .= Rapyd::script($script); } break; case "hidden": $output = Form::hidden($this->db_name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
/** * 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 __construct() { $this->tail = $this->tail = '<div class="row"><button type="submit" class="btn btn-primary">确定</button></div>' . Form::close(); }
/** * @param string $name * @param string $position * @param array $attributes * * @return $this */ function button($name, $position = "BL", $attributes = array()) { $attributes = array_merge(array("class" => "btn btn-default"), $attributes); $this->button_container[$position][] = Form::button($name, $attributes); return $this; }
private static function prv_getLabel($name, $label, $isRequired) { $labelRequired = $isRequired == true ? ' required' : ''; return Form::label($name, $label, array('class' => 'control-label col-lg-2 col-sm-4' . $labelRequired)); }
}); 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) {