<?php
namespace JF\JuridicusBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use JF\JuridicusBundle\Form\DataTransformer\StringToHandynummerTransformer;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
class HandynummerType extends AbstractType
{
private $vorwahlChoices;
public function __construct(array $vorwahlChoices = [])
{
$this->vorwahlChoices = $vorwahlChoices ?: ['+49', '+41', '+43'];
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('vorwahl', ChoiceType::class, array(
'required' => true,
'choices' => $this->vorwahlChoices,
'placeholder' => '----',
'attr' => array('class' => 'input-small')
))
->add('rufnummer', null, array(
'required' => true
))
;
$transformer = new StringToHandynummerTransformer();
$builder->addModelTransformer($transformer);
}
public function getParent()
{
return FormType::class; //changedFrom 'field'
}
public function getHandynummerType()
{
return 'handynummer';
}
public function getName()
{
return 'handynummer';
}
}