0

i have a form that binded to my class and everything works fine.

<form th:action="@{/createPost}" th:object="${newPost}" method="post" class="form-signin">

        <input type="text" th:field="*{topic}" class="new-post-topic-input" placeholder="post topic"
               autofocus="true"/>
</form>

I want to change my input css to a different style, but type='text' overwrites everything. But if i change input type to anything else, it doesn't bind values. Can i make thymeleaf see other input types to bind them?

UPDATE

i have bootstrap css file that contains css style for

But i want to have my own style for this input without deleting bootstrap css from page. But if i add class='anyClass' to this input, css from bootstrap from type='text' overwrites everything. And if i change type from text to anything else, thymeleaf doesn't map values anymore.

upd2 MY QUESTION IS NOT ABOUT CSS OVERRRIDING.

My question is about thymeleaf data object binding. I have th:object="${newPost}" in the form tag. Thymeleaf sees it and when i submit my form, it binds every , to fields of this object.

BUT if i change from type='text' to type='ANYTHING ELSE'> thymeleaf doesn't map anything. How can i make thymeleaf bind other tags like etc. To my object?

Ars
  • 591
  • 1
  • 4
  • 19
  • Can you please clarify your question? What do you want to change via CSS? What does `type='text'` overwrite? What has *input CSS* to do with the type of `input`? – cmoetzing Jun 06 '19 at 12:12
  • Possible duplicate of [How to override the properties of a CSS class using another CSS class](https://stackoverflow.com/questions/20954715/how-to-override-the-properties-of-a-css-class-using-another-css-class) – cmoetzing Jun 06 '19 at 12:19
  • Please provide a [mcve] with a description of what is not working as expected. It is not very helpfull if you talk about CSS styling when it has nothing to do with your problem. [The docu – cmoetzing Jun 07 '19 at 07:01

1 Answers1

0

The documentation clearly says it is possible to bind to other types:

Note that th:field also understands the new types of <input> element introduced by HTML5 like <input type="datetime" ... />, <input type="color" ... />, etc., effectively adding complete HTML5 support to Spring MVC.

The documentation also provides an example:

<div>
  <label th:for="${#ids.next('covered')}" th:text="#{seedstarter.covered}">Covered</label>
  <input type="checkbox" th:field="*{covered}" />
</div>

The field covered has to be of type boolean then of course. Please make sure the type of your input element matches the type of your field.

cmoetzing
  • 742
  • 3
  • 16