Search code examples
javahtmlliferayliferay-aui

liferay-ui input date clear value


How can I achieve a clear starting value for liferay-ui:input-date ?

When I try to use this:

<liferay-ui:input-date
monthParam="month"
monthValue="0"
monthNullable="<%= true %>"
dayParam="day"
dayValue="0"
dayNullable="<%= true %>"
yearParam="year"
yearValue="0"
yearNullable="<%= true %>"
/>

I get the following exception:

Attribute monthNullable invalid for tag input-date according to TLD

which I understand. When I remove the Nullable parameter and just set values to 0 the initial value is 12/31/1902... What I need to achieve, is to have no initial value of this field, unless it is chosen. Thank you for any kind of help.


Solution

  • In Liferay 6.2 InputDateTag has only one *nullable parameter - nullable. There's no monthNullable, dayNullable or yearNullable parameter. Hence the exception "Attribute *Nullable invalid for tag input-date according to TLD".

    All you need is to set nullable="true" and the initial value will be an empty String.

    The tag does the following:

    value="<%= nullable ? "" : format.format(calendar.getTime()) %>"