Description
calling setRequired(true); only activates Wicket's own required validation.
It should also set "required" attribute supported by HTML5 browsers so client-side UI experience will also match.
Example:
<form class="form form-horizontal" wicket:id="form"> <div class="control-group"> <label class="control-label" wicket:for="startDateFld">Start date</label> <div class="controls"> <input type="date" wicket:id="startDateFld" style="margin-right: 10px" required/> </div> </div> <div class="control-group"> <label class="control-label" wicket:for="endDateFld">End date</label> <div class="controls"> <input type="date" wicket:id="endDateFld" style="margin-right: 10px"/> </div> </div> </form>
final String datePattern = "yyyy-MM-dd"; startDateFld = new DateTextField("startDateFld", startDateModel, datePattern) { @Override protected String getInputType() { return "date"; }; }; startDateFld.setRequired(true); // buggy inside Modal // final DatePicker dateStartPicker = new DatePicker(); // dateStartPicker.setShowOnFieldClick(true); // dateStartPicker.setAutoHide(true); // startDateFld.add(dateStartPicker); form.add(startDateFld); final DateTextField endDateFld = new DateTextField("endDateFld", endDateModel, datePattern) { @Override protected String getInputType() { return "date"; }; }; endDateFld.setRequired(true);
startDateFld with "required" added manually is rendered correctly by Chrome. the endDateFld has a clear button, which is incorrect, because the field is required.