0

i'm creating a date picker in liferay alloy-ui. This code displays as default the date at this moment, but i want to set it null, cause i want that the user sets it. i tried to not display the date as input ,but the value of it, didn't change. Below is my code. Can anyone help me? thank you in advance.

div class="aui-datepicker aui-helper-clearfix" id="#<portlet:namespace/>beginDatePicker">
    <input type="text" name="beginDate" id="<portlet:namespace/>beginDate" size="30" value=""/>
</div>


<aui:script>
    AUI().use('aui-datepicker', function(A) {
      var simpleDatepicker1 = new A.DatePicker({
       trigger: '#<portlet:namespace />beginDate',
        }).render('##<portlet:namespace />beginDatePicker');
     });
</aui:script>

2 Answers2

0

I see that you use JSP. In this case I would use following liferay taglib tags:

<aui:field-wrapper name="beginDate" label="myBeginDate">
    <liferay-ui:input-date nullable="true" name="beginDate" dayParam="beginDateDay" monthParam="beginDateMonth" yearParam="beginDateYear"/>
</aui:field-wrapper>

AUI tag is used to provide compatibility with aui forms (layouting of label etc.). liferay-ui:input-date is used because aui don't define any date entry tag. nullable attribute delivers specifically what you need.

This will add following params to you request (if you use regular submit):

  • beginDateDay
  • beginDateMonth
  • beginDateYear

You can use them in your controller or jsp page to create date:

int day = ParamUtil.getInteger(request, "beginDateDay");
...
Date entryDate = PortalUtil.getDate(beginDateMonth, beginDateDay, ebeginDateYear);
Pawel Kruszewski
  • 559
  • 3
  • 10
0

Try this,

<aui:input id="beginDate" name="beginDate" class="form-control" type="text"  label="Begin Date" placeholder="mm/dd/yyyy" autocomplete="off" />

<aui:script>
var beginDatepicker = new Y.DatePicker({
        trigger : '#<portlet:namespace/>beginDate',
        mask : '%m/%d/%Y',
        popover : {
            zIndex : 1
        }
    });
</aui:script>

By default, you will get the placeholder "MM/dd/yyyy" in the date field, unless user enters or sets a date.

HTH

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
Harsha Kasturi
  • 233
  • 2
  • 13