propelorm/PropelBundle — pull request #201 by redexp (2012-12-28 18:53:35+00:00)
Title: added generation of Base*Type class

In Propel for symfony 1.4 forms have base class (which rewrites every time when schema was changed) and main class (which never rewrites). I'd like to have same thing in symfony 2.

Example

Foo\BarBundle\Form\Base\BaseUserType.php
```php
namespace Foo\BarBundle\Form\Type\Base;

use Propel\PropelBundle\Form\BaseAbstractType;
use Propel\PropelBundle\Form\Field;

class BaseUserType extends BaseAbstractType
{
protected function setup()
{
$this->setOptions(array(
'data_class' => 'Foo\BarBundle\Model\User',
'name' => 'user',
));

$this->setFields(array(
'name' => new Field(),
'password' => new Field(),
'created_at' => new Field(),
));
}
}
```

Foo\BarBundle\Form\UserType.php
```php
namespace Foo\BarBundle\Form\Type;

class UserType extends Base\BaseUserType
{
protected function configure()
{
$this->getField('created_at')
->setType('date')
->setOptions(array('widget'=>'single_text'))
;
}
}

```

and in BaseAbstractType we have implementation of buildForm()
```php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$this->setup();
$this->configure();
foreach($this->getFields() as $name => $field) {
$builder->add($name, $field->getType(), $field->getOptions());
}
}
```