本文整理汇总了PHP中Kris\LaravelFormBuilder\FormBuilder::create方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::create方法的具体用法?PHP FormBuilder::create怎么用?PHP FormBuilder::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kris\LaravelFormBuilder\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formUserDetail
/**
*
* @return \Kris\LaravelFormBuilder\Form
*/
private function formUserDetail()
{
$formUserDetail = $this->formBuilder->create('App\\Http\\Forms\\UserDetailForm', ['method' => 'PUT', 'url' => route('user.details.store'), 'model' => $this->userDetail]);
$formUserDetail->modify('avatar', 'file', ['value' => '']);
$formUserDetail->add('submit', 'submit', ['label' => 'Change your user details', 'attr' => ['class' => 'btn btn-primary btn-block']]);
return $formUserDetail;
}
示例2: show
/**
* Display the specified Blacklist Domain.
*
* @param BlacklistDomain $blacklistDomain
* @param FormBuilder $formBuilder
* @return Response
*/
public function show(BlacklistDomain $blacklistDomain, FormBuilder $formBuilder)
{
if ($blacklistDomain->zone_id) {
$zoneName = $blacklistDomain->zone->name;
} else {
$zoneName = trans('admin.blacklist_domain.global');
}
$form = $formBuilder->create('Admin\\BlacklistDomainForm', ['model' => $blacklistDomain])->add('zone_name', 'text', ['label' => trans('admin.blacklist_domain.field_zone_name'), 'default_value' => $zoneName, 'attr' => ['disabled' => 'disabled']]);
return view('admin.blacklist-domain.show', compact('form'));
}
示例3: contactUs
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function contactUs()
{
if (Auth::guest()) {
$user = new User();
} else {
$user = Auth::user();
}
$form = $this->formBuilder->create('App\\Http\\Forms\\ContactUsForm', ['method' => 'POST', 'url' => route('home.contact'), 'model' => $user]);
$form->add('send', 'submit', ['label' => 'Send this message', 'attr' => ['class' => 'btn btn-primary btn-block']]);
return view('home.contact_us', compact('form'));
}
示例4: edit
public function edit($id, Request $request, FormBuilder $formBuilder)
{
$permission = $this->permission->find($id);
$form = $formBuilder->create('App\\Forms\\PermissionForm', ['model' => $permission, 'method' => 'PUT', 'url' => route('admin.permissions.update', $id)]);
$script = 'js/backend/access/permissions/dependencies/script.js';
return view($request->ajax() ? 'layout.partials.ajax_form' : 'layout.partials.form', compact('form', 'script'));
}
示例5: compose
/**
* Take another form and add it's fields directly to this form
* @param mixed $class Form to merge
* @param array $options
* @param boolean $modify
* @return $this
*/
public function compose($class, array $options = [], $modify = false)
{
$options['class'] = $class;
// If we pass a ready made form just extract the fields
if ($class instanceof Form) {
$fields = $class->getFields();
} elseif ($class instanceof Fields\ChildFormType) {
$fields = $class->getForm()->getFields();
} elseif (is_string($class)) {
// If its a string of a class make it the usual way
$options['model'] = $this->model;
$options['name'] = $this->name;
$form = $this->formBuilder->create($class, $options);
$fields = $form->getFields();
} else {
throw new \InvalidArgumentException(
"[{$class}] is invalid. Please provide either a full class name, Form or ChildFormType"
);
}
foreach ($fields as $field) {
$this->addField($field, $modify);
}
return $this;
}
示例6: edit
public function edit($id, FormBuilder $formBuilder)
{
$result = IndustryType::findOrFail($id);
$form = $formBuilder->create('employment_bank\\Forms\\IndustryTypeForm', ['method' => 'PUT', 'model' => $result, 'url' => route($this->route . 'update', $id)])->remove('save');
//->setData('market_values', $markets);
return view($this->content . 'edit', compact('form'));
}
示例7: edit
/**
* Show the form for editing the specified article.
*
* @param Article $article
* @param FormBuilder $formBuilder
* @return Response
*/
public function edit(Article $article, FormBuilder $formBuilder)
{
$language = Session::get('current_lang');
$categories = $language->categories->lists('title', 'id')->all();
$form = $formBuilder->create('App\\Forms\\ArticlesForm', ['method' => 'PATCH', 'url' => route('admin.article.update', ['id' => $article->id]), 'model' => $article], $categories);
return view('admin.articles.edit', compact('form', 'article'));
}
示例8: store
public function store(FormBuilder $formBuilder)
{
$form = $formBuilder->create('App\\Forms\\SongForm');
if (!$form->isValid()) {
return redirect()->back()->withErrors($form->getErrors())->withInput();
}
// Do saving and other things...
}
示例9: store
public function store(FormBuilder $formBuilder, Request $request)
{
$form = $formBuilder->create(AdvertsForm::class);
if (!$form->isValid()) {
return redirect()->back()->withErrors($form->getErrors())->withInput();
}
Adverts::create($request->all());
return redirect()->route('advert.index');
}
示例10: defaultEdit
/**
* Render the form to $view when edit a record
*
* @param FormBuilder $formBuilder
* @param Model $model
* @param string $formName
* @param string $view
* @param string $modelName
* @return Response
*/
protected function defaultEdit(FormBuilder $formBuilder, Model $model, $formName, $view, $modelName = null)
{
$form = $formBuilder->create($formName, ['method' => 'PUT', 'url' => $this->route(explode('.', $view)[1] . '.update', ['id' => $model->id]), 'model' => $model]);
if ($modelName) {
return view($view, ['form' => $form, $modelName => $model]);
} else {
return view($view, compact('form'));
}
}
示例11: create
public function create(FormBuilder $formBuilder, $groupId = null)
{
$orgModel = [];
if (null !== $groupId) {
$orgModel = $this->orgGroupManager->getModelForUpdate($groupId);
}
$form = $formBuilder->create('App\\SuperAdmin\\Forms\\OrganizationGroup', ['method' => null !== $groupId ? 'PUT' : 'POST', 'url' => null !== $groupId ? route('admin.edit-group', [$groupId]) : route('admin.create-organization-group'), 'model' => $groupId ? $orgModel : null]);
return view('superAdmin.groupOrganization.create', compact('form', 'groupId'));
}
示例12: it_appends_default_namespace_from_config_on_building
/** @test */
public function it_appends_default_namespace_from_config_on_building()
{
$form = new LaravelFormBuilderTest\Forms\NamespacedDummyForm();
$config = $this->config;
$config['default_namespace'] = 'LaravelFormBuilderTest\\Forms';
$formHelper = new FormHelper($this->view, $this->translator, $config);
$formBuilder = new FormBuilder($this->app, $formHelper);
$formBuilder->create('NamespacedDummyForm');
}
示例13: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Request $request, FormBuilder $formBuilder, $page = null)
{
$applicationBySubjectList = new ApplicationBySubjectList($request, $this->main_page, $page);
$keys = $applicationBySubjectList->getKeys();
$data_arr = $applicationBySubjectList->getDataArr();
$paginationForm = $applicationBySubjectList->getPaginationForm();
$filter = session('application_by_subject_filter');
$form_filter = $formBuilder->create('App\\Filters\\ApplicationBySubjectFilter', ['method' => 'PATCH', 'action' => ['ApplicationBySubjectController@index'], 'model' => $filter, 'class' => 'form-inline']);
return view('list', ['controller' => 'ApplicationBySubjectController', 'data_arr' => $data_arr, 'keys' => $keys, 'perm_path' => $this->main_page, 'path' => $this->main_page, 'title' => 'APPLICATION_BY_SUBJECTS', 'filter' => $form_filter, 'pagination' => $paginationForm, 'add' => false, 'additional_info' => false, 'back' => false, 'parent_table_id' => false, 'edit' => false, 'delete' => false, 'modal' => true]);
}
示例14: add
/**
* Show the form required by an ajax request.
*
* @param $parent
* @param FormBuilder $formBuilder
*
* @return \Illuminate\Http\Response
*/
public function add(FormBuilder $formBuilder, $parent)
{
$articleComment = ArticleComment::whereId($parent)->get(['article_id'])->first();
$slug = Article::whereId($articleComment->article_id)->get(['slug'])->first();
$form = $formBuilder->create('\\App\\Http\\Forms\\ArticleCommentForm', ['method' => 'POST', 'id' => 'article_comment_form', 'url' => route('articles.comment.store')]);
$form->add('slug', 'hidden', ['value' => $slug->slug, 'attr' => ['id' => 'slug']]);
$form->add('parent_id', 'hidden', ['value' => $parent, 'attr' => ['id' => 'parent_id']]);
$form->add('save', 'submit', ['label' => 'Add your comment']);
return response()->view('articles.ajax_article_comment_show', compact('form'));
}
示例15: store
public function store(FormBuilder $formBuilder, Request $request)
{
$form = $formBuilder->create(StatesForm::class);
// It will automatically use current request, get the rules, and do the validation
if (!$form->isValid()) {
return redirect()->back()->withErrors($form->getErrors())->withInput();
}
States::create($request->all());
return redirect()->route('state.index');
}