How can i capture value changed for ui:inputDate and pass to server side controller. i have tried multiple ways but anything is not working
first controller function
componentValueChange : function(component,event){
var componentId =event.getSource().getLocalId(); // getting aura id value
var componentValue =component.find(componentId).get("v.value");// undefined...working for other input components
}
I have tried other way
https://developer.salesforce.com/forums/?id=906F0000000BJYcIAO
after capturing value from attribute and called server side function it went in infinite loop what i observed from above solution is at component initialize time it calling and once value change going into recursive.
please let me know if you have any solution to capturing the date value and store database record.
Best Answer
I tried the change event on the
ui:inputdate
, and the controller action does not seem to fire on change. Instead try creating a change handler that calls the defined action from controllerhttps://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_data_change.htm
component:
controller:
Update:
There is something off about the date, I assume it is the format in which the date is being passed. From official docs the basic data types should be supported. I tried integer and it passed fine to the apex controller.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_attr_types_basic.htm
I tried adjusting the format to YYYY-MM-DD still no luck I get null values when I pass this as date to the apex controller(*default format for dates in apex)
From this post :How to pass a <ui:inputdate> value from a clientside controller of a lightning component to a serverside controller's @Auraenabled method?
I see that you can pass the date as string and convert it back into a date in your apex controller. I was able to pass the date as string with no issues.
component:
controller:
apex controller: