Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Confirming form after form has been submitted and validated in Symfony

$
0
0

I have a appointment form once it has been submitted you get a confirmation of the data you've filled in, The confirmation has a button that when pressed on it it should insert the data to the database.

My question is, how to implement the button on the confirmation so it inserts?


I was thinking of making a if statement as this:

if ($form->isSubmitted() && $form->isValid()) {}

And within that if statement another if statement that would check if the button on the confirmation had been submitted so i could use the entitymanager to insert it in the database.

if ($form->isSubmitted() && $form->isValid()) {  if () {        $entityManager = $this->getDoctrine()->getManager();        $entityManager->persist($appointment);        $entityManager->persist($customer);        $entityManager->flush();  }}

The appointment form:The appointment form

The confirmation template:The confirmation template


The appointment form:

{% block body %}<p>new appointment</p>    {{ form_start(form) }}    {{ form_widget(form) }}<button class="btn">{{ button_label|default('Plan In') }}</button>    {{ form_end(form) }}{% endblock %}

The confirmation template

{% block body %}<p>confirm appointment</p><p>{{ customer_name }}</p><p>{{ customer_phone }}</p><p>{{ customer_email }}</p><hr><p>{{ barber_name }}</p><p>{{ treatment_name }}</p><p>{{ appointment_date|date('d-m-Y') }}</p><p>{{ appointment_time|date('H:i') }}</p><button class="btn">{{ button_label|default('Confirm') }}</button>{% endblock %}

If there is any confusion within my question please ask for clarification, And if you believe there is a better way of achieving what I want to achieve please suggest so.

Any help is appreciated, Thanks in advance.


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>