コード例 #1
0
ファイル: FormField.php プロジェクト: kyxer/barriosLaravel
 /**
  * Prepare options for rendering
  *
  * @param array $options
  * @return array
  */
 protected function prepareOptions(array $options = [])
 {
     $helper = $this->formHelper;
     if (array_get($this->options, 'template') !== null) {
         $this->template = array_pull($this->options, 'template');
     }
     $options = $this->options = $helper->mergeOptions($this->options, $options);
     if ($this->parent->haveErrorsEnabled()) {
         $this->addErrorClass($options);
     }
     if ($this->getOption('attr.multiple')) {
         $this->name = $this->name . '[]';
     }
     if ($this->getOption('required') === true) {
         $options['label_attr']['class'] .= ' ' . $this->formHelper->getConfig('defaults.required_class', 'required');
         $options['attr']['required'] = 'required';
     }
     $options['wrapperAttrs'] = $helper->prepareAttributes($options['wrapper']);
     $options['errorAttrs'] = $helper->prepareAttributes($options['errors']);
     if ($options['is_child']) {
         $options['labelAttrs'] = $helper->prepareAttributes($options['label_attr']);
     }
     if ($options['help_block']['text']) {
         $options['help_block']['helpBlockAttrs'] = $helper->prepareAttributes($options['help_block']['attr']);
     }
     return $options;
 }
コード例 #2
0
ファイル: FormField.php プロジェクト: Abdulhmid/wecan
 /**
  * Prepare options for rendering
  *
  * @param array $options
  * @return array
  */
 protected function prepareOptions(array $options = [])
 {
     $helper = $this->formHelper;
     $this->options = $helper->mergeOptions($this->options, $options);
     if ($this->getOption('attr.multiple') && !$this->getOption('tmp.multipleBracesSet')) {
         $this->name = $this->name . '[]';
         $this->setOption('tmp.multipleBracesSet', true);
     }
     if ($this->parent->haveErrorsEnabled()) {
         $this->addErrorClass();
     }
     if ($this->getOption('required') === true) {
         $lblClass = $this->getOption('label_attr.class', '');
         $requiredClass = $helper->getConfig('defaults.required_class', 'required');
         if (!str_contains($lblClass, $requiredClass)) {
             $lblClass .= ' ' . $requiredClass;
             $this->setOption('label_attr.class', $lblClass);
             $this->setOption('attr.required', 'required');
         }
     }
     if ($this->parent->clientValidationEnabled() && ($rules = $this->getOption('rules'))) {
         $rulesParser = new RulesParser($this);
         $attrs = $this->getOption('attr') + $rulesParser->parse($rules);
         $this->setOption('attr', $attrs);
     }
     $this->setOption('wrapperAttrs', $helper->prepareAttributes($this->getOption('wrapper')));
     $this->setOption('errorAttrs', $helper->prepareAttributes($this->getOption('errors')));
     if ($this->getOption('is_child')) {
         $this->setOption('labelAttrs', $helper->prepareAttributes($this->getOption('label_attr')));
     }
     if ($this->getOption('help_block.text')) {
         $this->setOption('help_block.helpBlockAttrs', $helper->prepareAttributes($this->getOption('help_block.attr')));
     }
     return $this->options;
 }