本文整理匯總了PHP中Anomaly\Streams\Platform\Ui\Form\FormBuilder::getForm方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormBuilder::getForm方法的具體用法?PHP FormBuilder::getForm怎麽用?PHP FormBuilder::getForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Anomaly\Streams\Platform\Ui\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getForm方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handle
/**
* Handle the form.
*/
public function handle()
{
$form = $this->builder->getForm();
$model = $this->builder->getModel();
/**
* If the model is already instantiated
* then use it as is.
*/
if (is_object($model)) {
$form->setModel($model);
return;
}
/**
* If no model is set, try guessing the
* model based on best practices.
*/
if ($model === null) {
$parts = explode('\\', str_replace('FormBuilder', 'Model', get_class($this->builder)));
unset($parts[count($parts) - 2]);
$model = implode('\\', $parts);
$this->builder->setModel($model);
}
/**
* If the model does not exist or
* is disabled then skip it.
*/
if (!$model || !class_exists($model)) {
$this->builder->setModel(null);
return;
}
/**
* Set the model on the form!
*/
$form->setModel(app($model));
}
示例2: handle
/**
* Handle the command.
*
* @param Container $container
*/
public function handle(Container $container)
{
/*
* Set the default options handler based
* on the builder class. Defaulting to
* no handler.
*/
if (!$this->builder->getRepository()) {
$model = $this->builder->getFormModel();
$entry = $this->builder->getEntry();
$form = $this->builder->getForm();
$repository = str_replace('FormBuilder', 'FormRepository', get_class($this->builder));
if (!$this->builder->getRepository() && class_exists($repository)) {
$this->builder->setRepository($container->make($repository, compact('form', 'model')));
} elseif (!$this->builder->getRepository() && $model instanceof EntryModel) {
$this->builder->setRepository($container->make(EntryFormRepository::class, compact('form', 'model')));
} elseif (!$this->builder->getRepository() && $model instanceof EloquentModel) {
$this->builder->setRepository($container->make(EloquentFormRepository::class, compact('form', 'model')));
} elseif (!$this->builder->getRepository() && $entry instanceof EntryModel) {
$this->builder->setRepository($container->make(EntryFormRepository::class, ['form' => $form, 'model' => $entry]));
} elseif (!$this->builder->getRepository() && $entry instanceof EloquentModel) {
$this->builder->setRepository($container->make(EloquentFormRepository::class, ['form' => $form, 'model' => $entry]));
}
}
}
示例3: handle
/**
* Handle the event.
*/
public function handle()
{
$form = $this->builder->getForm();
/* @var FieldType $field */
foreach ($form->getEnabledFields() as $field) {
$form->setValue($field->getInputName(), $field->getInputValue());
}
}
示例4: handle
/**
* Handle the command.
*
* @param MessageBag $messages
*/
public function handle(MessageBag $messages)
{
$form = $this->builder->getForm();
$errors = $form->getErrors();
if ($errors instanceof \Illuminate\Support\MessageBag) {
$messages->error($errors->all());
}
}
示例5: handle
/**
* Handle the command.
*/
public function handle()
{
$form = $this->builder->getForm();
$options = $form->getOptions();
$data = $form->getData();
$content = view($options->get('form_view'), $data->all());
$form->setContent($content);
$form->addData('content', $content);
}
示例6: handle
/**
* Handle the command.
*/
public function handle()
{
if (!$this->builder->canSave()) {
return;
}
$form = $this->builder->getForm();
foreach ($this->builder->getSkips() as $fieldSlug) {
$form->removeField($fieldSlug);
}
}
示例7: handle
public function handle()
{
$form = $this->builder->getForm();
$model = $this->builder->getModel();
if (is_string($model) && !class_exists($model)) {
return;
}
if (is_string($model)) {
$model = app($model);
}
if ($model instanceof EntryInterface) {
$form->setStream($model->getStream());
}
}
示例8: save
/**
* Save the form.
*
* @param FormBuilder $builder
* @return bool|mixed
*/
public function save(FormBuilder $builder)
{
$form = $builder->getForm();
$namespace = $form->getEntry() . '::';
/* @var FieldType $field */
foreach ($form->getFields() as $field) {
$this->preferences->set($namespace . $field->getField(), $form->getValue($field->getInputName()));
}
}
示例9: build
/**
* Build the actions.
*
* @param FormBuilder $builder
*/
public function build(FormBuilder $builder)
{
$form = $builder->getForm();
$this->input->read($builder);
foreach ($builder->getActions() as $action) {
if (array_get($action, 'enabled', true)) {
$form->addAction($this->factory->make($action));
}
}
}
示例10: handle
/**
* Handle the command.
*
* @param Container $container
* @param ViewTemplate $template
* @param BreadcrumbCollection $breadcrumbs
*/
public function handle(Container $container, ViewTemplate $template, BreadcrumbCollection $breadcrumbs)
{
$form = $this->builder->getForm();
if ($handler = $form->getOption('data')) {
$container->call($handler, compact('form'));
}
if ($layout = $form->getOption('layout_view')) {
$template->put('layout', $layout);
}
if ($title = $form->getOption('title')) {
$template->put('title', $title);
}
// Move this to options so we can read it.
$this->builder->setFormOption('read_only', $this->builder->isReadOnly());
$form->addData('form', $form);
if ($breadcrumb = $form->getOption('breadcrumb', 'streams::form.mode.' . $this->builder->getFormMode())) {
$breadcrumbs->put($breadcrumb, '#');
}
}
示例11: normalize
/**
* Normalize action input.
*
* @param FormBuilder $builder
*/
public function normalize(FormBuilder $builder)
{
$form = $builder->getForm();
$actions = $builder->getActions();
$prefix = $form->getOption('prefix');
foreach ($actions as $slug => &$action) {
$action = $this->process($prefix, $slug, $action);
}
$builder->setActions($actions);
}
示例12: save
/**
* Save the form.
*
* @param FormBuilder $builder
* @return bool|mixed
*/
public function save(FormBuilder $builder)
{
$form = $builder->getForm();
$namespace = $form->getEntry() . '::';
/* @var FieldType $field */
foreach ($form->getFields() as $field) {
$key = $namespace . $field->getField();
$value = $form->getValue($field->getInputName());
$this->settings->set($key, $value);
}
}
示例13: processSelfHandlingFields
/**
* Process fields that handle themselves.
*
* @param FormBuilder $builder
*/
protected function processSelfHandlingFields(FormBuilder $builder)
{
$form = $builder->getForm();
$entry = $form->getEntry();
$fields = $form->getFields();
$fields = $fields->selfHandling();
/* @var FieldType $field */
foreach ($fields as $field) {
app()->call([$field->setEntry($entry), 'handle'], compact('builder'));
}
}