onDataUnload()
The onDataUnload()
-callback is called whenever a complete set of current data is passed into the form by using the data(dat)
, -populateData(data)
- or populate(data, false)
-method
but right before the data were loaded into the form.
As you would need these methods only in very special cases you probably would hardly need this callback, but if you use it it allows you to perform actions right before the recent data will be overwritten with the new data.
onInitDataUnload()
The onInitDataUnload()
-callback is called whenever a complete set of initial data is loaded into the form by using the initData(dat)
, -populateRecord(data)
- or populate(data, true)
-method.
This can be very useful because by passing new initial data to the form you might loose some current data the user has entered. With the onInitDataUnload()
-method you could ask for unsaved changes whenever new initial data should be loaded into the form and abort this action if there are unsaved changes. The best would be to prompt the user with an alert asking him if he really wants to dismiss the changes and load new data into the form.
As far as one of the methods attached to the onInitDataUnload()
-callback returns false, the loading of the new data will be stopped.
emptyVal()
This method allows to set empty Values for empty properties. This can be useful because form elements like textfields or dates etc. return an empty string if they are empty. This might be a problem as you perhaps need to pass a null
-value to the server a certain the property is empty. This is very likely if you are dealing with dates as for example mysql expects a null
-value if no date is provided.
You can set multiple properties at once by putting their declarative representations into an array as done in the example. If there is only one property to apply an empty value you could pass it’s name as simple string.
As you can see uicForm3 provides the value of an unchecked checkbox if it is the only form element related to a particular property. This is because in this case it is normally used as switch transferring a boolean or something similar (could also be a yes or no or any other contrary pair of terms).