|
@@ -20,6 +20,7 @@ use Symfony\Component\Form\FormView;
|
|
|
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
|
|
|
use Symfony\Component\Form\Extension\Core\Validator\DefaultValidator;
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
|
|
+use Symfony\Component\Form\Exception\FormException;
|
|
|
|
|
|
class FieldType extends AbstractType
|
|
|
{
|
|
@@ -34,7 +35,10 @@ class FieldType extends AbstractType
|
|
|
} else {
|
|
|
$options['property_path'] = new PropertyPath($options['property_path']);
|
|
|
}
|
|
|
-
|
|
|
+ if (!is_array($options['attributes'])) {
|
|
|
+ throw new FormException('attributes option should be array');
|
|
|
+ }
|
|
|
+
|
|
|
$builder
|
|
|
->setRequired($options['required'])
|
|
|
->setReadOnly($options['read_only'])
|
|
@@ -46,6 +50,7 @@ class FieldType extends AbstractType
|
|
|
->setAttribute('max_length', $options['max_length'])
|
|
|
->setAttribute('pattern', $options['pattern'])
|
|
|
->setAttribute('label', $options['label'] ?: $this->humanize($builder->getName()))
|
|
|
+ ->setAttribute('attributes', $options['attributes'] ?: array())
|
|
|
->setData($options['data'])
|
|
|
->addValidator(new DefaultValidator())
|
|
|
;
|
|
@@ -88,7 +93,7 @@ class FieldType extends AbstractType
|
|
|
->set('size', null)
|
|
|
->set('label', $form->getAttribute('label'))
|
|
|
->set('multipart', false)
|
|
|
- ->set('attr', array())
|
|
|
+ ->set('attr', $form->getAttribute('attributes'))
|
|
|
->set('types', $types)
|
|
|
;
|
|
|
}
|
|
@@ -108,6 +113,7 @@ class FieldType extends AbstractType
|
|
|
'error_bubbling' => false,
|
|
|
'error_mapping' => array(),
|
|
|
'label' => null,
|
|
|
+ 'attributes' => array(),
|
|
|
);
|
|
|
|
|
|
$class = isset($options['data_class']) ? $options['data_class'] : null;
|