Ejemplo n.º 1
1
 /**
  * Add error class to wrapper if validation errors exist
  *
  * @param $options
  */
 protected function addErrorClass(&$options)
 {
     $errors = $this->parent->getRequest()->session()->get('errors');
     if ($errors && $errors->has($this->getNameKey())) {
         $errorClass = $this->formHelper->getConfig('defaults.wrapper_error_class');
         if ($options['wrapper'] && !str_contains($options['wrapper']['class'], $errorClass)) {
             $options['wrapper']['class'] .= ' ' . $errorClass;
         }
     }
     return $options;
 }
Ejemplo 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 . '\\';
 }
Ejemplo n.º 3
0
 /**
  * Add error class to wrapper if validation errors exist
  */
 protected function addErrorClass()
 {
     $errors = $this->parent->getRequest()->session()->get('errors');
     if ($errors && $errors->has($this->getNameKey())) {
         $errorClass = $this->formHelper->getConfig('defaults.wrapper_error_class');
         $wrapperClass = $this->getOption('wrapper.class');
         if ($this->getOption('wrapper') && !str_contains($wrapperClass, $errorClass)) {
             $wrapperClass .= ' ' . $errorClass;
             $this->setOption('wrapper.class', $wrapperClass);
         }
     }
 }
Ejemplo n.º 4
0
    /**
     * Render the form
     *
     * @param $options
     * @param $fields
     * @param boolean $showStart
     * @param boolean $showFields
     * @param boolean $showEnd
     * @return string
     */
    protected function render($options, $fields, $showStart, $showFields, $showEnd)
    {
        $formOptions = $this->formHelper->mergeOptions($this->formOptions, $options);

        $this->setupNamedModel();

        return $this->formHelper->getView()
            ->make($this->formHelper->getConfig('form'))
            ->with(compact('showStart', 'showFields', 'showEnd'))
            ->with('formOptions', $formOptions)
            ->with('fields', $fields)
            ->with('model', $this->getModel())
            ->with('exclude', $this->exclude)
            ->render();
    }
Ejemplo n.º 5
0
 /**
  * Get template from options if provided, otherwise fallback to config
  *
  * @return mixed
  */
 protected function getTemplate()
 {
     return $this->getTemplatePrefix() . $this->getFormOption('template', $this->formHelper->getConfig('form'));
 }