Thymeleaf - Submit information from inside table

0

Is it possible to give information submit from within one using thymeleaf?

Example:

<form method="post" th:action="@{/receive}" th:object="${objeto}" >
    <input type="text" th:field="*{nome}"/>                  
    <table>
        <thead>
            <tr>
                <th>Produto</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>palavra de testes</td>
            </tr>
        </tbody>
    </table>            
    <button type="submit">Enviar dados</button>            
</form>

In this case when I click the submit button, in my object only the name attribute will be populated, but in that same object I have an attribute of type List that I would like to populate from the values from within < table & gt ;. Is it possible?

    
asked by anonymous 19.01.2017 / 15:03

1 answer

0

I was able to send the information this way:

<form id="form1" th:action="@{/products}" th:object="${store}" method="post" th:method="POST" >
    <div>
        <input th:field="*{nome}" id="nome"/>
        <h5 class="center"> Product store items </h5>
        <table class="striped centered">
            <thead>
                <tr>
                    <th data-field="id"> Name </th>
                    <th data-field="name">Description </th>
                    <th data-field="price">Price </th>
                </tr>
            </thead>
            <tbody>
                <tr th:each="product, productStat : *{products}">
                    <td> <input type="text" th:field="*{products[__${productStat.index}__].name}" /> </td>
                    <td> <input type="text" th:field="*{products[__${productStat.index}__].description}" /> </td>
                    <td> <input type="text" th:field="*{products[__${productStat.index}__].price}" /> </td>
                    <td> <button type="submit" name="deleteProduct" class="btn-floating btn-small waves-effect waves-light" 
                                 th:value="${productStat.index}">
                            <i class="mdi-content-remove"></i></button>
                    </td>
                </tr>
            </tbody>
        </table>
        <button class=" btn waves-effect waves-light" type="submit" name="addProduct">Add product</button>
    </div>
    <button class=" btn waves-effect waves-light" type="submit" name="Enviar Informações">Submit</button>
</form>

Following this link: link

    
20.01.2017 / 13:30