A
A
Arthur2020-08-13 23:50:36
symfony
Arthur, 2020-08-13 23:50:36

How to find form controller in symfony?

As I understand it, a form is being created in a modal window with the "booking-form" template, but I can't find its controller in any way.

<div id="online_buy" class="modals-order" data-id="0" data-car="" style="display: none">
            {{ render(controller('WartFeedbackBundle:Front/FormGenerator:generateForm', {"formType": "booking", "formName": "Заявка на аренду", button: "Отправить заявку", template:'booking-form', "parameters" : { "page" : url } } )) }}
        </div>


Booking-form.html.twig content:
{{ form_start(form) }}
<div class="modal-main">
    <div class="content">
        <div class="title">
            ОНЛАЙН-ЗАКАЗ АВТО
        </div>

        <div class="information">
            <div class="information-title">
                ОБЩАЯ ИНФОРМАЦИЯ ЗАКАЗА
            </div>
            <div class="information-form">
                <div class="row-top">
                    <div class="title">ДАТА ПРОКАТА</div>
                    {{ form_widget(form.indate,  {attr: { 'placeholder': ''}}) }}
                    <label for="feedback_form_indate"></label>
                    <span>-</span>
                    {{ form_widget(form.outdate,  {attr: { 'class': 'js-datepicker', 'placeholder': ''}}) }}
                    <label for="feedback_form_outdate"></label>
                </div>
                <div class="row-bottom">
                    <div class="col-left">
                        {{ form_row(form.takeauto, { 'label': 'Место выдачи авто'}) }}
                    </div>
                    <div class="col-right">
                        {{ form_row(form.returnauto, { 'label': 'Место возврата авто'}) }}
                    </div>
                </div>
            </div>
        </div>

        <div class="addedService">
            <div class="addedService-title">
                ДОПОЛНИТЕЛЬНЫЕ УСЛУГИ
            </div>
            <div class="addedService-list">
                {% for tag in form.additional %}
                    <div class="addedService-item">
                        {{ form_widget(tag) }}
                    </div>
                {% endfor %}
            </div>
        </div>
        <div class="docs">
            <div class="docs-title">
                КОПИИ ДОКУМЕНТОВ
            </div>
            <div class="docs-description">
                    Для бронирования автомобиля необходимо согласование с нашей службой безопасности. Здесь вы можете прикрепить копии требуемых
                    документов или выслать их нам по E-Mail.
            </div>
            <div class="docs-row">

                <div class="docs-item">
                    <div class="docs-item__name">
                        Паспорт РФ
                    </div>
                    <div class="docs-item__text">
                        страницы с фотографией, пропиской, сведениях о ранее выданных паспортах
                    </div>
                    {{ form_widget(form.passport) }}

                </div>
                <div class="docs-item">
                    <div class="docs-item__name">
                        Водительское удостоверение
                    </div>
                    <div class="docs-item__text"></div>
                    {{ form_widget(form.drivelicence) }}

                </div>
                <div class="docs-item">
                    <div class="docs-item__name">
                        Третий документ, подтверждающий личность
                    </div>
                    <div class="docs-item__text">
                        СНИЛС, ИНН, заграничный паспорт, военный билет и т.д.
                    </div>
                    {{ form_widget(form.thirddocument) }}
                </div>
        </div>

        <div class="contactForm">
            <div class="contactForm-title">
                КОНТАКТНАЯ ИНФОРМАЦИЯ
            </div>
            <div class="contactForm-form">
                {{ form_widget(form.name,  {attr: { 'placeholder': 'ФИО'}}) }}
                {{ form_widget(form.phone,  {attr: { 'placeholder': '+7(___)___-__-__', 'minlength' : '11', 'pattern' : '[\+]?(7|8)[\\d]{10}'}}) }}
                {{ form_widget(form.email,  {attr: { 'placeholder': 'E-mail', 'pattern':'[a-zA-Z0-9(.-_)][email protected]+[a-z]+\\.+[a-z]{2,4}'}}) }}
                <label for="description">
                    ПРИМЕЧАНИЕ К ЗАКАЗУ
                </label>
                {{ form_widget(form.coment) }}
            </div>
        </div>
    
    <div style="padding-bottom:70px;" class="g-recaptcha" data-sitekey="6Lf5d74ZAAAAAB2PRFmp4BQg7-zaI2j3QxyizIss"></div>

</div>
</div>
</div>
<div class="order-footer">
    <a href="#" class="contactForm-btn btn">
        {{ form_widget(form.submit,  {"label" : button }) }}
    </a>
</div>

{{ form_end(form) }}


WHERE IS THE CONTROLLER OF THIS FORM??

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2020-08-14
@arturweb01

This controller, specified in the template, renders (creates) the form along the bundle:controller:action path , but processes another one/others. In general, the current template is called by the desired controller or several.
We are looking for a form processing controller:
1a. Or open the Google console tab Network -> XHR and when submitting the form, look at which route
1b is being sent to. Or open the Symfony debug console and when submitting the form, look at which route the submission is going to
2. Look for route: bin/consol debug:route <route>, where <route>is the path from path, you can search through grep: bin/console d:r | grep <route_part>
The command will give you something like this:

$ bin/console d:r home

+--------------+----------------------------------------------------------------+
| Property     | Value                                                          |
+--------------+----------------------------------------------------------------+
| Route Name   | home                                                           |
| Path         | /{_locale}                                                     |
| Path Regex   | {^/(?P<_locale>en|ru)?$}sDu                                    |
| Requirements | _locale: en|ru                                                 |
| Class        | Symfony\Component\Routing\Route                                |
| Defaults     | _controller: \App\Controller\HomeController::index() |
|              | _locale: en                                                    |
| Options      | compiler_class: Symfony\Component\Routing\RouteCompiler        |
|              | utf8: true                                                     |
+--------------+----------------------------------------------------------------+

but there may be variables (id, for example, or a slug), you need to do without them... in any case, you will find the path with the bin/consol debug:routename of your route on the command (on the right, the path with expressions, on the left, the name of the route - you need to substitute it in the first command):
users.show           ANY      ANY      ANY    /admin/users/{id}                                 
app_login            ANY      ANY      ANY    /login                                            
app_logout           GET      ANY      ANY    /logout                                                               
oauth.fake           ANY      ANY      ANY    /fake_login                                           
auth.signup          ANY      ANY      ANY    /signup

3. Somewhere there is a form processing, find something like that if ($form->isSubmitted() && $form->isValid())and already implement your captcha
4. PROFIT!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question