/** * @param Form $form * @return mixed */ public function formOpen(Form $form) { $options = $form->getAttributes(); $options['files'] = $form->files; if ($action = $form->action) { $options[$form->actionType] = $action; } if ($model = $form->model) { $html = $this->builder->model($model, $options); $form->fill(array_dot($model->toArray())); } else { $html = $this->builder->open($options); } return $html; }
/** * Open the form, and add the fields for an specific action or the default fields if no action is defined. * * @param string|null $action * @param array $attributes * * @return string */ public function open($action = null, array $attributes = array()) { if (is_array($action)) { $attributes = $action; $action = null; } $form = $this->formFor($action); $attributes = array_merge($attributes, ['method' => $this->method, 'url' => $this->action, 'files' => $this->hasFile()]); if ($this->model) { return $this->builder->model($this->model, $attributes); } else { return $this->builder->open($attributes); } }
/** * Parse the model binding and set the appropriate keys for * routing. * * @param array $options * @return array */ protected function parseModelBinding($options) { // If the form is passed a model, we'll use the update route to update // the model using the PUT method. if (isset($options['model']) && $options['model']->getKey()) { $options['route'] = array($options['update'], $options['model']->getKey()); $options['method'] = 'put'; } else { if (isset($options['store'])) { $options['route'] = $options['store']; $options['method'] = 'post'; } } //bind the model to the form and remove it from the options $this->form->model($options['model']); array_forget($options, 'model'); // Forget the routes provided to the input. array_forget($options, 'update'); array_forget($options, 'store'); return $options; }
/** * Create a new model based form builder. * * @param mixed $model * @param array $options * @return string * @static */ public static function model($model, $options = array()) { return \Illuminate\Html\FormBuilder::model($model, $options); }
public function populate($form, array $options = array()) { return $this->form->model($form->getData(), $options); }
/** * Create a new model based form builder. * * @param array $rules Laravel validation rules * * @see Illuminate\Html\FormBuilder */ public function model($model, array $options = array(), $rules = null) { $this->setValidation($rules); return parent::model($model, $options); }