vendredi 8 juillet 2016

Hidden input in thymeleaf with wrong value

in GET method I'm adding this to model:

model.addAttribute("team", team);
model.addAttribute("players", team.getPlayers());
model.addAttribute( "inviting", new InvitingPlayerToTeam() );

And a fragment of view with this model:

<div id = "news" th:fragment="playerList">

            <span>Nazwa: </span>
            <span th:text = "${team.name}">nazwa teamu</span>
            <br>
            <span th:each = "player : ${players}" th:utext = "${player.username} + '</br>'">-</span>
            <br>
            <br>
            <form method = "POST" th:action="@{/team/invitePlayer}" th:object = "${inviting}">
                Nazwa <input type = "text" th:field = "*{username}"> 
                <input type = "hidden" th:field = "*{teamId}" th:value="${team.id}" >
                <br>
                <input type = "submit" value = "Zaproś">
            </form>
    </div>

And what is wrong ? In post method field inviting.username has good value, but inviting.teamId is 0 .. Where is the problem ?

Aucun commentaire:

Enregistrer un commentaire