model() public method

Create a new model based form builder.
public model ( mixed $model, array $options = [] ) : Illuminate\Support\HtmlString
$model mixed
$options array
return Illuminate\Support\HtmlString
Exemplo n.º 1
0
 /**
  * Open a form configured for model binding.
  *
  * @param  array  $options
  * @return string
  */
 protected function model($options)
 {
     $model = $options['model'];
     if (isset($options['url'])) {
         // If we're explicity passed a URL, we'll use that.
         array_forget($options, ['update', 'store']);
         $options['method'] = isset($options['method']) ? $options['method'] : 'GET';
         return $this->form->model($model, $options);
     }
     if (!is_null($options['model']) && $options['model']->exists) {
         // If the form is passed a model, we'll use the update route to update
         // the model using the PUT method.
         $route = Str::contains($options['update'], '@') ? 'action' : 'route';
         $options[$route] = [$options['update'], $options['model']->getRouteKey()];
         $options['method'] = 'PUT';
     } else {
         // Otherwise, we're storing a brand new model using the POST method.
         $route = Str::contains($options['store'], '@') ? 'action' : 'route';
         $options[$route] = $options['store'];
         $options['method'] = 'POST';
     }
     // Forget the routes provided to the input.
     array_forget($options, ['model', 'update', 'store']);
     return $this->form->model($model, $options);
 }
 public function model($model, array $options = array())
 {
     // always set up validation, whether output by this tag or not
     $this->_setUpValidation($model, $options);
     // set up form ID
     if (array_key_exists('validate', $options) && $options['validate']) {
         $this->npmValidate = true;
     }
     // pass to parent
     $this->npmModel = $model;
     $results = parent::model($model, $options);
     if (Generator::START == $this->gen->getCodePosition()) {
         $results .= $this->generateClientValidatorCode();
     }
     return $results;
 }
Exemplo n.º 3
0
 /**
  * Open a form configured for model binding.
  *
  * @param  array  $options
  * @return string
  */
 protected function model($options)
 {
     $model = $options['model'];
     // If the form is passed a model, we'll use the update route to update
     // the model using the PUT method.
     if (!is_null($options['model']) && $options['model']->exists) {
         $update = is_array($options['update']) ? $options['update'][0] : $options['update'];
         $route = Str::contains($update, '@') ? 'action' : 'route';
         $options[$route] = array_merge((array) $options['update'], [$options['model']->getRouteKey()]);
         $options['method'] = 'PUT';
     } else {
         // Otherwise, we're storing a brand new model using the POST method.
         $store = is_array($options['store']) ? $options['store'][0] : $options['store'];
         $route = Str::contains($store, '@') ? 'action' : 'route';
         $options[$route] = $options['store'];
         $options['method'] = 'POST';
     }
     // Forget the routes provided to the input.
     array_forget($options, ['model', 'update', 'store']);
     return $this->form->model($model, $options);
 }
Exemplo n.º 4
0
 /**
  * Create a new model based form builder.
  *
  * @param mixed $model
  * @param array $options
  * @return string 
  * @static 
  */
 public static function model($model, $options = array())
 {
     return \Collective\Html\FormBuilder::model($model, $options);
 }
Exemplo n.º 5
0
 /**
  * Create a new model based form builder.
  * @param \LaravelArdent\Ardent\Ardent $model An Ardent model instance. Validation rules will be taken from it
  * @param array                        $options
  * @return string
  * @see Collective\Html\FormBuilder
  */
 public function model($model, array $options = [])
 {
     $this->setValidation($model::$rules);
     return parent::model($model, $options);
 }
Exemplo n.º 6
0
 /**
  * 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);
 }
Exemplo n.º 7
0
 public function model($model, array $options = [])
 {
     $this->initializeForm($options);
     return parent::model($model, $options);
 }