Defining onchange methods
When writing business logic, it is often the case that some fields are interrelated. We looked at how to specify constraints between fields in the Adding constraint validations to a model recipe in Chapter 4, Application Models. This recipe illustrates a slightly different concept. Here, onchange
methods are called when a field is modified in the user interface to update the values of other fields of the record in the web client, usually in a form view.
We will illustrate this by providing a wizard similar to the one defined in the Writing a wizard to guide the user recipe, but that can be used to record duration returns. When a date is set in the form view, the duration is updated for the student. While we are demonstrating onchange
methods on Model
, these features are also available on normal Transient
models.
Getting ready
For this recipe, we will use the my_hostel
module from the Writing a form to guide the user recipe of this chapter. We will...