У меня есть эта форма, которая работала, пока я не добавил datetimepicker.Теперь кнопка отправки даже не работает, ничего не отправляется в БД.У кого-нибудь будет идея, почему?Спасибо!
Я не получил печально известную красную полосу, Symfony не сообщает об ошибках ...
контроллер
public function newReservation(request $request)
{
$reservation = new Contact();
$em = $this->getDoctrine()->getRepository(Contact::class);
$form = $this->createForm(ReservationType::class, $reservation,array());
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$reservation->setName($form['name']->getData());
$reservation->setContent($form['content']->getData());
$reservation->setParticipant($form['kidNumber']->getData()+$form['adultNumber']->getData());
$reservation->setReservationStart($form['reservationStart']->getData());
$reservation->setReservationEnd($form['reservationEnd']->getData());
$reservation->setReservationStart2($form['reservation_start2']->getData());
$reservation->setReservationEnd2($form['reservation_end2']->getData());
$reservation->setContactName($form['contactName']->getData());
$reservation->setEmail($form['email']->getData());
$reservation->setPhone($form['phone']->getData());
$reservation->setSubject($form['subject']->getData());
$reservation->setDateSubmit(new \DateTime());
$reservation->setKidNumber($form['kidNumber']->getData());
$reservation->setAdultNumber($form['adultNumber']->getData());
$reservation->setAddress($form['address']->getData());
$reservation->setStatus('En attente');
$em = $this->getDoctrine()->getManager();
$em->persist($reservation);
$em->flush();
$this->addFlash(
'notice',
'Demande envoyée'
);
return $this->redirectToRoute('admin');
}
return $this->render('reservation/reservation.html.twig', array(
'form' => $form->createView(),
'reservation' => $reservation
)
);
}
форма
class ReservationType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('subject', EntityType::class, [
'class' => Subject::class,
'choice_label' => 'name',
'label' => 'Choisir un type de réservation',
'placeholder' => ' ',
])
->add('name', TextType::class, array('label'=>'Organisme', 'attr' => array(
'class' => 'form-control',
'title' => 'Organisme',
)))
->add('contactName', TextType::class, array('label'=>'Nom de la personne à contacter', 'attr' => array(
'class' => 'form-control',
'title' => 'Organisme',
)))
->add('reservationStart', DateTimeType::class, array(
'label'=>'Date de début - Premier choix',
'time_widget'=> 'single_text',
'date_widget'=>'single_text',
'attr' => array(
'class' => 'datetimepicker',
'data-format' => 'dd-mm-yyyy HH:ii',
'title' => 'Save',
)))
->add('reservationEnd', DateTimeType::class, array(
'label'=>'Date de fin - Premier choix',
'time_widget' => 'single_text',
'date_widget' => 'single_text',
'attr' => array(
'class' => 'datetimepicker',
'title' => 'Save',
)))
->add('reservation_start2', DateTimeType::class, array(
'label'=>'Date de début - Second choix',
'time_widget'=> 'single_text',
'date_widget'=>'single_text',
'attr' => array(
'class' => 'datetimepicker',
'title' => 'Save',
)))
->add('reservation_end2', DateTimeType::class, array(
'label'=>'Date de fin - Second choix',
'time_widget' => 'single_text',
'date_widget' => 'single_text',
'attr' => array(
'class' => 'datetimepicker',
'title' => 'Save',
)))
->add('email', EmailType::class, array('label'=>'Email', 'attr' => array(
'class' => 'form-control',
'title' => 'Email',
)))
->add('kidNumber', IntegerType::class, array('label'=>'Nombre d\'enfants', 'attr' => array(
'class' => 'form-control',
'title' => 'Nombre d\'enfant',
)))
->add('adultNumber', IntegerType::class, array('label'=>'Nombre d\'adultes', 'attr' => array(
'class' => 'form-control',
'title' => 'Nombre d\'adulte',
)))
->add('phone', TelType::class, array('label'=>'Téléphone', 'attr' => array(
'class' => 'form-control',
'title' => 'Telephone',
)))
->add('address', TextType::class, array('label'=>'Adresse', 'attr' => array(
'class' => 'form-control',
'title' => 'Adresse',
)))
->add('content', TextareaType::class, array('label'=>'Donnez nous plus d\'informations', 'attr' => array(
'class' => 'form-control',
'title' => 'Content',
)));
$builder
->add('save', SubmitType::class, array(
'label' => 'Envoyer la demande!',
'attr' => array(
'class' => 'btn btn-primary btn-margin',
'title' => 'Faire une demande'
)
));
}
}
Я не вижу, в чем проблема.