Affects Version/s: 1.8.2, 1.9, 2.0
Fix Version/s: None
Component/s: Forms Library
Affected Branches:MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
The definition_after_data function in formslib is defined as:
"This method is called after definition(), data submission and set_data(). All form setup that is dependent on form values should go in here."
This makes it a very useful function to provide non-trivial form function. The trouble is, that it is being called many times (up to 3) from a form, with no indicator of what function is calling it (state).
This function could be rendered much more useful if it passed a state value indicating which of the three possible callers is calling it. That way, code could act on the appropriate case.
So, something like:
definition_after_data ($state = 'unknown');
where $state is 'definition', 'submission', 'set_data', etc.