Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Sergei Makarov](https://secure.gravatar.com/avatar/ae9951d9ab2ad1a2480508fad8b2aa17?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sergei Makarov
13,839 PointsUsing Thymeleaf-Form Tempalte to set Values to Fields of Class
Sorry, but I really do not understand, how works a thymeleaf processing in background. I mean, as long as our Class Category does have only one constructor without any parameters, don't we need to use setName method in the field of input tag (don't really know, if it possible, to use methods in Templates, but eventually).
...
<form th:action="@{/categories}" method="post" th:object="${category}">
...
<div class="col s12 l8"> <input type="text" th:field="*{name}" placeholder="Category Name"/> </div>
I just mean. how does thymeleaf know to use setName method, instead of using a getName() for example? Is it cause of POST.method? I wouldn't confused, if we had a constructor with field Name and Color, but as long as we don't, it seems to be strange for me.
Aidan Melendez
5,637 PointsAidan Melendez
5,637 PointsHey Sergei, I know I may be late in answering your question. But for anyone who may find this question and was wondering the same thing, it is as simple as Thymeleaf calling the category's objects "getName()" function.
for anyone who would like to read further on the subject, here is a link for the Thymeleaf documentation!
http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#using-thtext-and-externalizing-text