4

My problem is that I'm not able to get the date with a month number format.

This is my code:

    <ui:inputDate aura:id="input" 
        value="2018-01-01"
        format="dd-MM-yyyy"
        displayDatePicker="true"
        disabled="true"
        required="true" />

As we can see, the input is disabled by default, so if we enable the inputDate again we'll see that the month is showing as string and not as a number, here is an example:

enter image description here

How could I force the ui component to show month as a number? Am I doing something wrong?

0

I've made up a quick solution, but I think it should be a better solution. This is my code:

    <aura:if isTrue="{!(!v.disabled)}">
        <ui:inputDate aura:id="input" 
            value="{!v.date}"
            format="dd/MM/yyyy"
            displayDatePicker="true"
            required="{!v.required}" />
    <aura:set attribute="else">
        <ui:inputDate aura:id="input" displayDatePicker="true" disabled="{!v.disabled}"/>
    </aura:set>
    </aura:if>

This causes the disabled input to be destroyed, when the disabled status change, and a new one is rendered without being disabled by default and, thus, with the desired format.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.