W
W
wolverine7772019-04-16 12:28:34
symfony
wolverine777, 2019-04-16 12:28:34

How to use buttons to move from page to page in symfony?

Hello, I'm trying to figure out how to navigate from page to page after clicking a button in symfony?
It would seem very simple - just specify a link to the page - but for some reason in one direction (when you click on the link) - the transition occurs, but if you immediately want to go back - when you click on the "back" BUTTON, not only with empty fields the form "does not release" (says that the fields must be filled before the button does its job) and does not return to the specified path, but simply reloads the page (well, this is an opinion at least).
So I have the following question:
How to get rid of the need to fill in the fields before clicking the "BACK" button
Here is what I have:

TWIG:

{% block body %}

    <font color="#1E4262"> <h1 align="center">- Creation of a book -</h1></font>

    <table class="cadre" border="1">
        <tbody>
        {{ form_start(post_form) }}
        <tr style="line-height: 3px;" >
            <td>&nbsp; </td>
        </tr>

        <tr>
            <td align="right"><label for=""><b>Name *: </b></label></td>
            <td> {{ form_widget(post_form.title) }} </td>
        </tr>

        <tr>
            <td align="right"><label for=""><b>Description : </b></label></td>
            <td> {{ form_widget(post_form.description) }} </td>
        </tr>



        <tr>
            <td>
                <h6>* must be filled.</h6>
            </td>


            <td class="alignRight" colspan="2">
                <a href="/reader"><button type="submit" >BACK</button></a>
                <button type="reset" >RESET</button>
                <button type="submit" >SAVE</button>
            </td>
        </tr>
        {{ form_end(post_form) }}
        </tbody>
    </table>

{% endblock %}

CONTROLLER:


    /**
     * @Route("/reader/new", name="new_reader")
     */
    public function create(Request $request)

    {

        $post = new Site();
        $form = $this->createForm(NewReaderType::class, $post);

        $form->handleRequest($request);


        return $this->render('reader/new.html.twig', [

            'post_form' => $form->createView()


        ]);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eobard Thawne, 2019-04-18
@vexgg

Watch these videos, there are 3 of them, despite the fact that it is in English, it is very clear. https://www.youtube.com/watch?v=kfiKn5c9l84
In general, I think you need to work with annotations, but I don’t know for sure, I’m just learning Symfony myself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question