diff --git a/Form/BaseAbstractType.php b/Form/BaseAbstractType.php new file mode 100644 index 0000000..26fd39b --- /dev/null +++ b/Form/BaseAbstractType.php @@ -0,0 +1,61 @@ + '', + ); + + function __construct($mergeOptions = null) + { + if ($mergeOptions) { + $this->mergeOptions($mergeOptions); + } + } + + public function setOption($name, $value) + { + $this->options[$name] = $value; + } + + public function getOption($name) + { + return $this->options[$name]; + } + + public function setOptions($options) + { + $this->options = $options; + } + + public function getOptions() + { + return $this->options; + } + + public function mergeOptions($options) + { + $this->options = array_merge($this->options, $options); + } + + /** + * {@inheritdoc} + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults($this->options); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->getOption('name'); + } +} diff --git a/Resources/skeleton/FormType.php b/Resources/skeleton/FormType.php index 5fdc0b4..2afd3ea 100644 --- a/Resources/skeleton/FormType.php +++ b/Resources/skeleton/FormType.php @@ -2,34 +2,20 @@ namespace ##NAMESPACE##; -use Symfony\Component\Form\AbstractType; +use Propel\PropelBundle\Form\BaseAbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; -class ##CLASS## extends AbstractType +class ##CLASS## extends BaseAbstractType { + protected $options = array( + 'data_class' => '##FQCN##', + 'name' => '##TYPE_NAME##', + ); + /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) {##BUILD_CODE## } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'data_class' => '##FQCN##', - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return '##TYPE_NAME##'; - } }