コード例 #1
0
 /** @test */
 public function it_load_custom_field_types_from_config()
 {
     $config = $this->config;
     $config['custom_fields']['datetime'] = 'App\\Forms\\DatetimeType';
     $formHelper = new FormHelper($this->view, $this->request, $config);
     $this->assertEquals('App\\Forms\\DatetimeType', $formHelper->getFieldType('datetime'));
 }
コード例 #2
0
ファイル: FormBuilder.php プロジェクト: Abdulhmid/wecan
 /**
  * Get the namespace from the config
  *
  * @return string
  */
 protected function getNamespaceFromConfig()
 {
     $namespace = $this->formHelper->getConfig('default_namespace');
     if (!$namespace) {
         return '';
     }
     return $namespace . '\\';
 }
コード例 #3
0
ファイル: Form.php プロジェクト: adhikjoshi/D-provider
 /**
  * Set namespace to model if form is named so the data is bound properly
  */
 protected function setupNamedModel()
 {
     if (!$this->getModel() || !$this->getName()) {
         return;
     }
     $model = $this->formHelper->convertModelToArray($this->getModel());
     if (!array_get($model, $this->getName())) {
         $this->model = [$this->getName() => $model];
     }
 }
コード例 #4
0
 protected function setupLabel()
 {
     if ($this->getOption('label') !== null) {
         return;
     }
     if ($langName = $this->parent->getLanguageName()) {
         $label = sprintf('%s.%s', $langName, $this->getRealName());
     } else {
         $label = $this->getRealName();
     }
     $this->setOption('label', $this->formHelper->formatLabel($label));
 }
コード例 #5
0
 /**
  * Get validatdion rules for the form
  *
  * @param array $overrideRules
  * @return array
  */
 public function getRules($overrideRules = [])
 {
     $fieldRules = $this->formHelper->mergeFieldsRules($this->fields);
     return array_merge($fieldRules['rules'], $overrideRules);
 }
コード例 #6
0
 /**
  * Get the title, used for validating a rule
  *
  * @param  string $rule
  * @param  array  $params
  * @return string
  */
 protected function getTitle($rule, $params = array())
 {
     $params['attribute'] = $this->formHelper->formatLabel($this->field->getName());
     return trans('validation.' . $rule, $params);
 }
コード例 #7
0
 /**
  * Merge all defaults with field specific defaults and set template if passed
  *
  * @param array $options
  */
 protected function setDefaultOptions(array $options = [])
 {
     $this->options = $this->formHelper->mergeOptions($this->allDefaults(), $this->getDefaults());
     $this->options = $this->prepareOptions($options);
 }
コード例 #8
0
 /**
  * Get the title, used for validating a rule
  *
  * @param  string $rule
  * @param  array  $params
  * @return string
  */
 protected function getTitle($rule, $params = array())
 {
     $params['attribute'] = $this->field->getOption('label');
     return $this->formHelper->getTranslator()->trans('validation.' . $rule, $params);
 }