本文整理汇总了PHP中FormBuilder::create方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::create方法的具体用法?PHP FormBuilder::create怎么用?PHP FormBuilder::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: profile
/**
* Show the user profile.
*
* @return Response
*/
public function profile()
{
try {
$user = User::with('groups')->findOrFail(Auth::user()->id);
Debugbar::info($user->toArray());
$user_form = \FormBuilder::create('Isabry\\Gatekeeper\\Forms\\UserForm', ['model' => $user])->remove('password')->remove('password_confirmation');
return view('gatekeeper::home.profile')->with(compact('user_form'))->with('user', $user);
} catch (ModelNotFoundException $e) {
Session::flash('error', 'User not found (id: ' . $id . ')');
return Redirect::intended('/');
}
}
示例2: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$class = $this->params['model'];
$entry = $class::find($id);
$form = \FormBuilder::create($this->params['form'], ['method' => 'PUT', 'model' => $entry, 'url' => route("{$this->params['route']}.update", [$id]), 'data' => $this->params['form_data']]);
$tplPath = base_path('resources/views/' . $this->params['tpl_path']);
if (is_dir($tplPath)) {
$view = "{$this->params['tpl_path']}.edit";
} else {
$view = 'crud::entry.edit';
}
return view($view, compact('form'));
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
try {
$user = User::with('groups')->findOrFail($id);
Debugbar::info($user->toArray());
$user_form = \FormBuilder::create('Isabry\\Gatekeeper\\Forms\\UserForm', ['model' => $user])->remove('password')->remove('password_confirmation');
$url = '<a role="button" href="' . route('users.index') . '" class="btn btn-primary">' . ' <i class="fa fa-mail-reply"></i> Back to Users List' . '</a>';
return view('gatekeeper::users.view')->with('title', 'User (' . $user->name . ')')->with(compact('user_form'))->with('url', $url);
} catch (ModelNotFoundException $e) {
Session::flash('error', 'User not found (id: ' . $id . ')');
return Redirect::intended('users');
}
}
示例4: attributes
/**
* Attributes name from field label
*
* @return [string]
*/
public function attributes()
{
if ($this->form) {
$attributes = [];
$formFields = \FormBuilder::create($this->form)->getFields();
foreach ($formFields as $name => $fields) {
if ($fields->getOptions()['label']) {
$attributes[$name] = $fields->getOptions()['label'];
}
}
return $attributes;
}
return [];
}