Ejemplo n.º 1
0
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     dd(parent::getParent());
     $choice = new ChoiceType('some_choice', 'choice', new Form(), $options);
     return $choice->render();
     //return parent::render($options, $showLabel, $showField, $showError);
 }
Ejemplo n.º 2
0
 /**
  * @param array $options
  * @param bool  $showLabel
  * @param bool  $showField
  * @param bool  $showError
  * @return string
  */
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     $options['mode'] = 'multiple';
     $options['getter_method'] = 'get_nodes_by_ids';
     $options['getter_method_params'] = [false];
     $options['search_route'] = 'reactor.nodes.search.json';
     return parent::render($options, $showLabel, $showField, $showError);
 }
Ejemplo n.º 3
0
 /**
  * @param array $options
  * @param bool  $showLabel
  * @param bool  $showField
  * @param bool  $showError
  *
  * @return string
  */
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     $options = array_merge($this->getOptions(), $options);
     $options['url'] = array_get($options, 'url', '#');
     $options['label'] = array_get($options, 'label', 'Link');
     $options['attr'] = array_get($options, 'attr', ['class' => '']);
     return parent::render($options, $showLabel, $showField, $showError);
 }
 /**
  * @inheritdoc
  */
 public function isRendered()
 {
     foreach ((array) $this->children as $key => $child) {
         if ($child->isRendered()) {
             return true;
         }
     }
     return parent::isRendered();
 }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  */
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     if (isset($options['attr']) && is_array($options['attr'])) {
         $options['attr']['class'] = !empty($options['attr']['class']) ? $options['attr']['class'] . ' lavanda-image-upload' : $this->options['attr']['class'] . ' lavanda-image-upload';
     } else {
         $options['attr'] = ['class' => $this->options['attr']['class'] . ' lavanda-image-upload'];
     }
     if ($this->getValue()) {
         $options['rules'] = str_replace(['required|', '|required', 'required'], '', $this->getOption('rules'));
         if (isset($this->options['attr']['required'])) {
             unset($this->options['attr']['required']);
         }
     }
     return parent::render($options, $showLabel, $showField, $showError);
 }
Ejemplo n.º 6
0
 /**
  * Add a FormField to the form's fields
  *
  * @param FormField $field
  * @return $this
  */
 protected function addField(FormField $field, $modify = false)
 {
     if (!$modify && !$this->rebuilding) {
         $this->preventDuplicate($field->getRealName());
     }
     if ($field->getType() == 'file') {
         $this->formOptions['files'] = true;
     }
     $this->fields[$field->getRealName()] = $field;
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * {@inheritDoc}
  */
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     $preparedOptions = $this->prepareOptions($options);
     $options['attr']['data-format'] = $preparedOptions['format'];
     return parent::render($options, $showLabel, $showField, $showError);
 }
 /**
  * Check if the field is one of certain types.
  *
  * @param  string|array  $types
  * @return bool
  */
 protected function isType($types)
 {
     return in_array($this->field->getType(), (array) $types);
 }
Ejemplo n.º 9
0
 /**
  * Add a FormField to the form's fields
  *
  * @param FormField $field
  * @return $this
  */
 protected function addField(FormField $field, $modify = false)
 {
     if (!$modify && !$this->rebuilding) {
         $this->preventDuplicate($field->getRealName());
     }
     $this->fields[$field->getRealName()] = $field;
     return $this;
 }
 /**
  * Prepare collection for prototype by adding prototype as child
  * @param FormField $field
  */
 public function preparePrototype(FormField $field)
 {
     if (!$field->getOption('is_prototype')) {
         throw new \InvalidArgumentException('Field [' . $field->getRealName() . '] is not a valid prototype object.');
     }
     $this->children = [];
     $this->children[] = $field;
 }
Ejemplo n.º 11
0
 function form_errors(FormField $formField, array $options = [])
 {
     return $formField->render($options, false, false, true);
 }
Ejemplo n.º 12
0
 /**
  * @inheritdoc
  */
 public function getValidationRules()
 {
     $rules = parent::getValidationRules();
     $childrenRules = $this->formHelper->mergeFieldsRules($this->children);
     return array_replace_recursive($rules, $childrenRules);
 }
Ejemplo n.º 13
0
 /**
  * Set up a single child element for a collection
  *
  * @param FormField $field
  * @param           $name
  * @param null      $value
  * @return FormField
  */
 protected function setupChild(FormField $field, $name, $value = null)
 {
     $newFieldName = $field->getName() . $name;
     $firstFieldOptions = $this->formHelper->mergeOptions($this->getOption('options'), ['attr' => ['id' => $newFieldName]]);
     $field->setName($newFieldName);
     $field->setOptions($firstFieldOptions);
     if ($value && !$field instanceof ChildFormType) {
         $value = $this->getModelValueAttribute($value, $this->getOption('property'));
     }
     $field->setValue($value);
     return $field;
 }