open() public method

Open up a new HTML form.
public open ( array $options = [] ) : Illuminate\Support\HtmlString
$options array
return Illuminate\Support\HtmlString
Exemplo n.º 1
0
 /**
  * Return the opening form tag.
  *
  * @param array $options
  * @return string
  */
 public function open(array $options = [])
 {
     if ($url = $this->object->getOption('url')) {
         $options['url'] = $url;
     }
     return $this->html->open($options);
 }
 /**
  * Open a form while passing a model and the routes for storing or updating
  * the model. This will set the correct route along with the correct
  * method.
  *
  * @param  array $options
  *
  * @return string
  */
 public function open(array $options = [])
 {
     // Set the HTML5 role.
     $options['role'] = 'form';
     // Set the class for the form type.
     if (!array_key_exists('class', $options)) {
         $options['class'] = $this->getType();
     }
     if (array_key_exists('left_column_class', $options)) {
         $this->setLeftColumnClass($options['left_column_class']);
     }
     if (array_key_exists('left_column_offset_class', $options)) {
         $this->setLeftColumnOffsetClass($options['left_column_offset_class']);
     }
     if (array_key_exists('right_column_class', $options)) {
         $this->setRightColumnClass($options['right_column_class']);
     }
     if (array_key_exists('label_required_mark', $options)) {
         $this->setLabelRequiredMark($options['label_required_mark']);
     }
     if (array_key_exists('group_required_class', $options)) {
         $this->setLabelRequiredMark($options['group_required_class']);
     }
     array_forget($options, ['left_column_class', 'left_column_offset_class', 'right_column_class', 'label_required_mark', 'group_required_class']);
     if (array_key_exists('model', $options)) {
         return $this->model($options);
     }
     return $this->form->open($options);
 }
Exemplo n.º 3
0
 /**
  * Open up a new HTML form. 
  * Sets "form-horizontal" as the default class for forms.
  *
  * @param  array   $options
  * @return string
  */
 public function open(array $options = array())
 {
     if (!isset($options['class'])) {
         $options['class'] = 'form-horizontal';
     }
     return parent::open($options);
 }
Exemplo n.º 4
0
 /**
  * Open up a new HTML form and pass the optional novalidate option.
  * This methods relies on the original Form::open method of the Laravel
  * Collective component.
  *
  * @param array $options
  *
  * @return string
  */
 public function open(array $options = array())
 {
     if ($this->novalidate()) {
         $options[] = 'novalidate';
     }
     return parent::open($options);
 }
Exemplo n.º 5
0
 /**
  * Open a form while passing a model and the routes for storing or updating
  * the model. This will set the correct route along with the correct
  * method.
  *
  * @param  array  $options
  * @return string
  */
 public function open(array $options = [])
 {
     // Set the HTML5 role.
     $options['role'] = 'form';
     // Set the class for the form type.
     if (!array_key_exists('class', $options)) {
         $options['class'] = $this->getType();
     }
     if (array_key_exists('left_column_class', $options)) {
         $this->setLeftColumnClass($options['left_column_class']);
     }
     if (array_key_exists('left_column_offset_class', $options)) {
         $this->setLeftColumnOffsetClass($options['left_column_offset_class']);
     }
     if (array_key_exists('right_column_class', $options)) {
         $this->setRightColumnClass($options['right_column_class']);
     }
     // Set the name of the error bag to pull from the session.  The default is "default".
     // This allows multiple forms to be on the same page without error messages colliding
     if (array_key_exists('errorBag', $options)) {
         $this->errorBag = $options['errorBag'];
     }
     array_forget($options, ['left_column_class', 'left_column_offset_class', 'right_column_class', 'errorBag']);
     if (array_key_exists('model', $options)) {
         return $this->model($options);
     }
     return $this->form->open($options);
 }
Exemplo n.º 6
0
 public function open(array $options = [])
 {
     if (array_key_exists('model', $options)) {
         PkForm::setModel($options['model']);
         unset($options['model']);
     }
     return parent::open($options);
 }
 /**
  * @param array $options
  *
  * @return string
  */
 public function open(array $options = [])
 {
     $themeName = array_get($options, 'theme', config('rutorika-form.theme'));
     $themeClass = config('rutorika-form.themes.' . $themeName);
     $this->theme = new $themeClass($this);
     $options = $this->theme->updateOptions($options);
     return parent::open($options);
 }
Exemplo n.º 8
0
 /**
  * Opens form with a set of validation rules
  * @param array $rules Laravel validation rules
  * @see Collective\Html\FormBuilder
  * @return string
  */
 public function open(array $options = [], $rules = null)
 {
     $this->setValidation($rules);
     if (isset($options['name'])) {
         $this->converter->setFormName($options['name']);
     } else {
         $this->converter->setFormName(null);
     }
     return parent::open($options);
 }
Exemplo n.º 9
0
 /**
  * Open a form while passing a model and the routes for storing or updating
  * the model. This will set the correct route along with the correct
  * method.
  *
  * @param  array  $options
  * @return string
  */
 public function open(array $options = [])
 {
     // Set the HTML5 role.
     $options['role'] = 'form';
     // Set the class for the form type.
     if (!isset($options['class'])) {
         $options['class'] = $this->getType();
     }
     if (isset($options['left_column_class'])) {
         $this->setLeftColumnClass($options['left_column_class']);
     }
     if (isset($options['left_column_offset_class'])) {
         $this->setLeftColumnOffsetClass($options['left_column_offset_class']);
     }
     if (isset($options['right_column_class'])) {
         $this->setRightColumnClass($options['right_column_class']);
     }
     array_forget($options, ['left_column_class', 'left_column_offset_class', 'right_column_class']);
     if (isset($options['model'])) {
         return $this->model($options);
     }
     return $this->form->open($options);
 }
Exemplo n.º 10
0
 /**
  * Open up a new HTML form.
  *
  * @param array $options
  * @return string 
  * @static 
  */
 public static function open($options = array())
 {
     return \Collective\Html\FormBuilder::open($options);
 }
Exemplo n.º 11
0
 public function open(array $options = [])
 {
     $this->initializeForm($options);
     return parent::open($options);
 }
Exemplo n.º 12
0
Form::macro('delete', function ($route, $id, $text = '', $tooltip = false, $icon = true) {
    $model = explode('.', $route);
    $model = ucfirst(substr($model[1], 0, -1));
    $tooltip = $tooltip ? $tooltip : 'Deletar ' . $model;
    $out = Form::open(['route' => [$route . '.destroy', $id], 'method' => 'DELETE', 'data-id' => $id, 'style' => 'display: inline-block']);
    $out .= '<button data-toggle="tooltip" data-placement="top" data-original-title="' . $tooltip . '" type="submit" data-id="' . $id . '" class="btn btn-danger btn-sm ' . ($icon ? 'btn-fw' : '') . '">';
    $out .= $icon ? '<i class="fa fa-times"></i> &nbsp;' . $text : $text;
    $out .= '</button>';
    $out .= Form::close();
    return $out;
});
Form::macro('undelete', function ($route, $id, $text = '', $tooltip = false) {
    $model = explode('.', $route);
    $model = ucfirst(substr($model[1], 0, -1));
    $tooltip = $tooltip ? $tooltip : 'Reativar ' . $model;
    $out = Form::open(['route' => [$route . '.undestroy', $id], 'method' => 'PUT', 'data-confirm' => $id . '-ativar', 'style' => 'display: inline-block']);
    $out .= '<button data-toggle="tooltip" data-placement="top"
        data-original-title="' . $tooltip . '" type="submit" data-confirm="' . $id . '-ativar" class="btn btn-warning btn-fw btn-sm">';
    $out .= '<i class="fa fa-undo"></i> &nbsp;' . $text;
    $out .= '</button>';
    $out .= Form::close();
    return $out;
});
Form::macro('edit', function ($route, $id, $text = '', $tooltip = false) {
    $model = explode('.', $route);
    $model = ucfirst(substr($model[1], 0, -1));
    $tooltip = $tooltip ? $tooltip : 'Editar ' . $model;
    $out = '<a data-toggle="tooltip" data-placement="top" data-original-title="' . $tooltip . '" href="' . route($route . '.edit', $id) . '" class="btn btn-fw btn-success btn-sm">';
    $out .= '<i class="fa fa-pencil"></i> &nbsp;' . $text;
    $out .= '</a>';
    return $out;