I am creating a custom form type in symfony2. But every time I try to overwrite the buildForm() method I get this error:
Fatal error: Declaration of SeduceMe\SiteBundle\Form\Type\UniFormTextType::buildView() must be compatible with that of Symfony\Component\Form\FormTypeInterface::buildView() in /Users/alexander/Projekte/SeduceMe/serversymfony204/src/SeduceMe/SiteBundle/Form/Type/UniFormTextType.php on line 33
Of course I understand what this means. I even copied the method signature from the mentioned interface. Still the same. This is my class:
namespace SeduceMe\SiteBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class UniFormTextType extends AbstractType
{
public function getDefaultOptions(array $options)
{
return array('placeholder' => null);
}
public function getParent(array $options)
{
return 'text';
}
public function getName()
{
return 'UniFormText';
}
public function buildForm(FormBuilder $builder, array $options)
{
$builder->setAttribute('placeholder', $options['placeholder']);
}
public function buildView(FormView $view, FormInterface $form)
{
$view->set('placeholder', $form->getAttribute('placeholder'));
}
}