Ad

I Have This Code, When Submited The Form Dont Refresh, Someone Know How Refresh After Submit On October Cms?

- 1 answer

<form data-request="onSend" data-request-update="'{{ __SELF__}}::attbanco': '#banco' "
  data-request-flash  >

<table>

    <tr>
        <td>Nome: </td> <td ><input type="text" id="nome" name="nome"></td>
    </tr>

    <tr>
        <td>Idade: </td> <td ><input type="number" id="idade" name="idade" value="{{usuario.idade}}"></td>
    </tr>

    <tr>
        <td>Telefone: </td> <td ><input type="text" id="telefone" name="telefone" value="{{usuario.telefone}}"></td>
    </tr>

</table>

<button type="submit" >Enviar</button>

<input type="hidden" value="{{usuario.id}}" name="id">

this code work, saves the values on database, but i need manually refresh page to see the result on my screen, someone know how refresh after submit? Please, explain most simple possible, i am newbie

Ad

Answer

The best way to do what you want is to put the form in a partial and update it when the form is submitted.

Replace your form with this:

<div id="specialForm">
{% partial __SELF__~"::specialForm" %}
</div>

Create a partial to describe the form; I used specialForm. It should reload the form and clear the content.

<form data-request="onSend" data-request-update="'{{ __SELF__}}::attbanco': '#banco', '{{ __SELF__ }}::specialForm': '#specialForm' "
  data-request-flash  >

    <table>

        <tr>
            <td>Nome: </td> <td ><input type="text" id="nome" name="nome"></td>
        </tr>

        <tr>
            <td>Idade: </td> <td ><input type="number" id="idade" name="idade" value="{{usuario.idade}}"></td>
        </tr>

        <tr>
            <td>Telefone: </td> <td ><input type="text" id="telefone" name="telefone" value="{{usuario.telefone}}"></td>
        </tr>

    </table>

    <button type="submit" >Enviar</button>

    <input type="hidden" value="{{usuario.id}}" name="id">

</form>
Ad
source: stackoverflow.com
Ad