Skip to content
Snippets Groups Projects
Commit ce262966 authored by Stephane Nicoll's avatar Stephane Nicoll
Browse files

Merge pull request #303 from arey:feature/date

* pr/303:
  Add placeholder YYYY-MM-DD for date input field
parents fadf7f4d d92a4218
No related branches found
No related tags found
No related merge requests found
<html> <html>
<body> <body>
<form> <form>
<th:block th:fragment="input (label, name)"> <th:block th:fragment="input (label, name, type)">
<div th:with="valid=${!#fields.hasErrors(name)}" <div th:with="valid=${!#fields.hasErrors(name)}"
th:class="${'form-group' + (valid ? '' : ' has-error')}" th:class="${'form-group' + (valid ? '' : ' has-error')}"
class="form-group"> class="form-group">
<label class="col-sm-2 control-label" th:text="${label}">Label</label> <label class="col-sm-2 control-label" th:text="${label}">Label</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input class="form-control" type="text" <div th:switch="${type}">
th:field="*{__${name}__}" /> <input th:case="'text'" class="form-control" type="text" th:field="*{__${name}__}" />
<input th:case="'date'" class="form-control" type="text" th:field="*{__${name}__}"
placeholder="YYYY-MM-DD" title="Enter a date in this format: YYYY-MM-DD"
pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))"/>
</div>
<span th:if="${valid}" <span th:if="${valid}"
class="glyphicon glyphicon-ok form-control-feedback" class="glyphicon glyphicon-ok form-control-feedback"
aria-hidden="true"></span> aria-hidden="true"></span>
......
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
<form th:object="${owner}" class="form-horizontal" id="add-owner-form" method="post"> <form th:object="${owner}" class="form-horizontal" id="add-owner-form" method="post">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<input <input
th:replace="~{fragments/inputField :: input ('First Name', 'firstName')}" /> th:replace="~{fragments/inputField :: input ('First Name', 'firstName', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Last Name', 'lastName')}" /> th:replace="~{fragments/inputField :: input ('Last Name', 'lastName', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Address', 'address')}" /> th:replace="~{fragments/inputField :: input ('Address', 'address', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('City', 'city')}" /> th:replace="~{fragments/inputField :: input ('City', 'city', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Telephone', 'telephone')}" /> th:replace="~{fragments/inputField :: input ('Telephone', 'telephone', 'text')}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-offset-2 col-sm-10"> <div class="col-sm-offset-2 col-sm-10">
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
</div> </div>
</div> </div>
<input <input
th:replace="~{fragments/inputField :: input ('Name', 'name')}" /> th:replace="~{fragments/inputField :: input ('Name', 'name', 'text')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate')}" /> th:replace="~{fragments/inputField :: input ('Birth Date', 'birthDate', 'date')}" />
<input <input
th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" /> th:replace="~{fragments/selectField :: select ('Type', 'type', ${types})}" />
</div> </div>
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
<form th:object="${visit}" class="form-horizontal" method="post"> <form th:object="${visit}" class="form-horizontal" method="post">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<input <input
th:replace="~{fragments/inputField :: input ('Date', 'date')}" /> th:replace="~{fragments/inputField :: input ('Date', 'date', 'date')}" />
<input <input
th:replace="~{fragments/inputField :: input ('Description', 'description')}" /> th:replace="~{fragments/inputField :: input ('Description', 'description', 'text')}" />
</div> </div>
<div class="form-group"> <div class="form-group">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment