/** @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'));
 }
Esempio n. 2
0
 /**
  * Get the namespace from the config
  *
  * @return string
  */
 protected function getNamespaceFromConfig()
 {
     $namespace = $this->formHelper->getConfig('default_namespace');
     if (!$namespace) {
         return '';
     }
     return $namespace . '\\';
 }
Esempio n. 3
0
 /**
  * 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];
     }
 }
Esempio n. 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));
 }
Esempio n. 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);
 }
 /**
  * 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);
 }
Esempio n. 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);
 }
 /**
  * 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);
 }