• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Form\FormBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Form\FormBuilder的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder类的具体用法?PHP FormBuilder怎么用?PHP FormBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FormBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: guess

 /**
  * Guess the nullable rule.
  *
  * @param FormBuilder $builder
  */
 public function guess(FormBuilder $builder)
 {
     $fields = $builder->getFields();
     foreach ($fields as &$field) {
         // Skip if nullable
         if (isset($field['rules']) && in_array('nullable', $field['rules'])) {
             continue;
         }
         /**
          * If the field depends on other fields we
          * won't add nullable here because validation
          * will not be performed on this field.
          */
         if (!empty($field['rules'])) {
             if (preg_grep("/required_.*/", $field['rules'])) {
                 continue;
             }
         }
         // If not required then nullable.
         if (isset($field['required']) && $field['required'] == false) {
             $field['rules'][] = 'nullable';
         }
         // If not specified then it's nullable
         if (!isset($field['required'])) {
             $field['rules'][] = 'nullable';
         }
     }
     $builder->setFields($fields);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:34,代码来源:NullableGuesser.php


示例2: guess

 /**
  * Guess the HREF for a button.
  *
  * @param FormBuilder $builder
  */
 public function guess(FormBuilder $builder)
 {
     $buttons = $builder->getButtons();
     $entry = $builder->getFormEntry();
     // Nothing to do if empty.
     if (!($section = $this->sections->active())) {
         return;
     }
     foreach ($buttons as &$button) {
         if (isset($button['attributes']['href'])) {
             continue;
         }
         switch (array_get($button, 'button')) {
             case 'cancel':
                 $button['attributes']['href'] = $section->getHref();
                 break;
             case 'delete':
                 $button['attributes']['href'] = $section->getHref('delete/' . $entry->getId());
                 break;
             default:
                 // Determine the HREF based on the button type.
                 $type = array_get($button, 'button');
                 if ($type && !str_contains($type, '\\') && !class_exists($type)) {
                     $button['attributes']['href'] = $section->getHref($type . '/{entry.id}');
                 }
                 break;
         }
     }
     $builder->setButtons($buttons);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:35,代码来源:HrefGuesser.php


示例3: handle

 /**
  * Handle the form.
  *
  * @param FormBuilder $builder
  */
 public function handle(FormBuilder $builder)
 {
     if (!$builder->canSave()) {
         return;
     }
     $builder->saveForm();
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:12,代码来源:FormHandler.php


示例4: translate

 /**
  * Translate form fields.
  *
  * @param FormBuilder $builder
  */
 public function translate(FormBuilder $builder)
 {
     $translations = [];
     $defaultLocale = config('streams::locales.default');
     $enabledLocales = config('streams::locales.enabled');
     /*
      * For each field if the assignment is translatable
      * then duplicate it and set a couple simple
      * parameters to assist in rendering.
      */
     foreach ($builder->getFields() as $field) {
         if (!array_get($field, 'translatable', false)) {
             $translations[] = $field;
             continue;
         }
         foreach ($enabledLocales as $locale) {
             $translation = $field;
             array_set($translation, 'locale', $locale);
             array_set($translation, 'hidden', $locale !== $locale);
             if ($value = array_get($field, 'values.' . $locale)) {
                 array_set($translation, 'value', $value);
             }
             if ($defaultLocale !== $locale) {
                 array_set($translation, 'hidden', true);
                 array_set($translation, 'required', false);
                 array_set($translation, 'rules', array_diff(array_get($translation, 'rules', []), ['required']));
             }
             $translations[] = $translation;
         }
     }
     $builder->setFields($translations);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:37,代码来源:FieldTranslator.php


示例5: guess

 /**
  * Guess the button from the hint.
  *
  * @param FormBuilder $builder
  */
 public function guess(FormBuilder $builder)
 {
     $buttons = $builder->getButtons();
     $module = $this->modules->active();
     /*
      * This will break if we can't figure
      * out what the active module is.
      */
     if (!$module instanceof Module) {
         return;
     }
     foreach ($buttons as &$button) {
         if (isset($button['text'])) {
             continue;
         }
         if (!isset($button['button'])) {
             continue;
         }
         $text = $module->getNamespace('button.' . $button['button']);
         if (!isset($button['text']) && $this->translator->has($text)) {
             $button['text'] = $text;
         }
         if ((!isset($button['text']) || !$this->translator->has($button['text'])) && $this->config->get('streams::system.lazy_translations')) {
             $button['text'] = ucwords($this->string->humanize($button['button']));
         }
         if (!isset($button['text'])) {
             $button['text'] = $text;
         }
     }
     $builder->setButtons($buttons);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:36,代码来源:TextGuesser.php


示例6: 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));
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:38,代码来源:SetFormModel.php


示例7: save

 /**
  * Save the form.
  *
  * @param FormBuilder|ConfigurationFormBuilder $builder
  * @return bool|mixed
  */
 public function save(FormBuilder $builder)
 {
     $namespace = $builder->getFormEntry() . '::';
     /* @var FieldType $field */
     foreach ($builder->getFormFields() as $field) {
         $this->configurations->set($namespace . $field->getField(), $builder->getScope(), $builder->getFormValue($field->getInputName()));
     }
 }
开发者ID:bloveless,项目名称:configuration-module,代码行数:14,代码来源:ConfigurationFormRepository.php


示例8: normalize

 /**
  * Normalize button input.
  *
  * @param FormBuilder $builder
  */
 public function normalize(FormBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as $key => &$button) {
         $button = $this->process($key, $button);
     }
     $builder->setButtons($buttons);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:13,代码来源:ButtonNormalizer.php


示例9: guess

 /**
  * Guess the field placeholders.
  *
  * @param FormBuilder $builder
  */
 public function guess(FormBuilder $builder)
 {
     $fields = $builder->getFields();
     $prefix = $builder->getFormOption('prefix');
     foreach ($fields as &$field) {
         array_set($field, 'prefix', array_get($field, 'prefix', $prefix));
     }
     $builder->setFields($fields);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:14,代码来源:PrefixesGuesser.php


示例10: 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()));
     }
 }
开发者ID:AkibaTech,项目名称:preferences-module,代码行数:15,代码来源:PreferenceFormRepository.php


示例11: all

 /**
  * Return all the input from the form.
  *
  * @param  FormBuilder $builder
  * @return array
  */
 public function all(FormBuilder $builder)
 {
     $input = [];
     /* @var FieldType $field */
     foreach ($builder->getEnabledFormFields() as $field) {
         $input[$field->getInputName()] = $field->getValidationValue();
     }
     return $input;
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:15,代码来源:FormInput.php


示例12: handle

 /**
  * Set the form model object from the builder's model.
  *
  * @param SetDefaultParameters $command
  */
 public function handle()
 {
     /*
      * Set the form mode according
      * to the builder's entry.
      */
     if (!$this->builder->getFormMode()) {
         $this->builder->setFormMode($this->builder->getFormEntryId() || $this->builder->getEntry() ? 'edit' : 'create');
     }
     /*
      * Next we'll loop each property and look for a handler.
      */
     $reflection = new \ReflectionClass($this->builder);
     /* @var \ReflectionProperty $property */
     foreach ($reflection->getProperties(\ReflectionProperty::IS_PROTECTED) as $property) {
         if (in_array($property->getName(), $this->skips)) {
             continue;
         }
         /*
          * If there is no getter then skip it.
          */
         if (!method_exists($this->builder, $method = 'get' . ucfirst($property->getName()))) {
             continue;
         }
         /*
          * If the parameter already
          * has a value then skip it.
          */
         if ($this->builder->{$method}()) {
             continue;
         }
         /*
          * Check if we can transform the
          * builder property into a handler.
          * If it exists, then go ahead and use it.
          */
         $handler = str_replace('FormBuilder', 'Form' . ucfirst($property->getName()), get_class($this->builder));
         if (class_exists($handler)) {
             /*
              * Make sure the handler is
              * formatted properly.
              */
             if (!str_contains($handler, '@')) {
                 $handler .= '@handle';
             }
             $this->builder->{'set' . ucfirst($property->getName())}($handler);
             continue;
         }
         /*
          * If the handler does not exist and
          * we have a default handler, use it.
          */
         if ($default = array_get($this->defaults, $property->getName())) {
             $this->builder->{'set' . ucfirst($property->getName())}($default);
         }
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:62,代码来源:SetDefaultParameters.php


示例13: defaults

 /**
  * Default the form actions when none are defined.
  *
  * @param FormBuilder $builder
  */
 public function defaults(FormBuilder $builder)
 {
     if ($builder->getActions() === []) {
         if ($builder->getFormMode() == 'create') {
             $builder->setActions(['save', 'save_create']);
         } else {
             $builder->setActions(['update', 'save_exit']);
         }
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:15,代码来源:ActionDefaults.php


示例14: 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);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:15,代码来源:ActionNormalizer.php


示例15: merge

 /**
  * Merge in registered properties.
  *
  * @param FormBuilder $builder
  */
 public function merge(FormBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as &$parameters) {
         if ($button = $this->buttons->get(array_get($parameters, 'button'))) {
             $parameters = array_replace_recursive($button, $parameters);
         }
     }
     $builder->setButtons($buttons);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:15,代码来源:ButtonLookup.php


示例16: normalize

 /**
  * Normalize the sections.
  *
  * @param FormBuilder $builder
  */
 public function normalize(FormBuilder $builder)
 {
     $sections = $builder->getSections();
     foreach ($sections as $slug => &$section) {
         if (is_string($section)) {
             $section = ['view' => $section];
         }
     }
     $builder->setSections($sections);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:15,代码来源:SectionNormalizer.php


示例17: 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));
         }
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:15,代码来源:ActionBuilder.php


示例18: 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);
     }
 }
开发者ID:Wol,项目名称:settings-module,代码行数:17,代码来源:SettingFormRepository.php


示例19: handle

 /**
  * Handle the command.
  *
  * @param Resolver  $resolver
  * @param Evaluator $evaluator
  */
 public function handle(Resolver $resolver, Evaluator $evaluator)
 {
     $evaluator->evaluate($resolver->resolve($this->builder->getOptions(), ['builder' => $this->builder]), ['builder' => $this->builder]);
     foreach ($this->builder->getOptions() as $key => $value) {
         $this->builder->setFormOption($key, $value);
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:13,代码来源:SetFormOptions.php


示例20: handle

 /**
  * Handle the event.
  */
 public function handle(Store $session)
 {
     /* @var MessageBag $errors */
     if ($errors = $session->get($this->builder->getOption('prefix') . 'errors')) {
         $this->builder->setFormErrors($errors);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:10,代码来源:LoadFormErrors.php



注:本文中的Anomaly\Streams\Platform\Ui\Form\FormBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Table\TableBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP Amp\resolve函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap