Я решил проблему
Контроллер
public function sendSmsAction(Request $request)
{
try{
$form = $this->createForm(smsFormType::class, array('telephone' => $request->get('telephones')));
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$message = $form->get('message')->getData();
$smsProvider = $this->get('app.sms.provider');
$phoneNumbers=$form->getConfig()->getData();
$smsProvider->sendMessage($message, $phoneNumbers);
}
} catch (InvalidParameterException $e) {
sprintf("Erreur lors de l'envoie de SMS, il faut choisir un utilisateur : %s . Trace : %s", $e->getMessage(), $e->getTraceAsString()
);
throw $e;
}
return $this->render('CeUtilisateurBundle:Utilisateur:sms.html.twig', array(
'form' => $form->createView()));
}
formType
class smsFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('telephone', HiddenType::class, array(
'data' => $options['telephone'],
))
->add('message', TextareaType::class, array(
'attr' => ['class' => 'tinymce',
'placeholder' => 'Votre message',
],
'label' => false,
'required' => true))
->add('Envoyer', SubmitType::class, array(
'attr' => array(
'class' => 'btn btn-primary',
)
));
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'telephone' => null
));
}
}