I think you have to explore the form-events for a better understanding.
setup
Triggered once when the form is created for the first time
before_load
Triggered before the form is about to load
onload
Triggered when the form is loaded and is about to render
refresh
Triggered when the form is loaded and rendered.
onload_post_render
Triggered after the form is loaded and rendered
validate
Triggered before before_save
before_save
Triggered before save is called
after_save
Triggered after form is saved
before_submit
Triggered before submit is called
on_submit
Triggered after form is submitted
before_cancel
Triggered before cancel is called
after_cancel
Triggered after form is cancelled
before_discard
Triggered before discard is called
after_discard
Triggered after form is discarded
timeline_refresh
Triggered after form timeline is rendered
{fieldname}_on_form_rendered
Triggered when a row is opened as a form in a Table field
{fieldname}
Triggered when the value of fieldname is changed
get_email_recipient_filters
Called by the email dialog to fetch default filters for email recipients. Should accept two parameters frm (the current form) and field (“recipients”, “cc” or “bcc”), and return an array or dict of filters (related to the Contact doctype).
get_email_recipients
Called by the email dialog to fetch default recipients. Should accept two parameters frm (the current form) and field (“recipients”, “cc” or “bcc”), and return a list of email addresses for this field.