本文整理汇总了PHP中Illuminate\Html\FormBuilder::model方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::model方法的具体用法?PHP FormBuilder::model怎么用?PHP FormBuilder::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Html\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formOpen
/**
* @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;
}
示例2: open
/**
* 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);
}
}
示例3: parseModelBinding
/**
* 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;
}
示例4: model
/**
* 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);
}
示例5: model
/**
* 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);
}
示例6: populate
public function populate($form, array $options = array())
{
return $this->form->model($form->getData(), $options);
}