Posted by sun on
- Form constructor functions have no way to figure out the original $form_id name for which the form is currently built for.
- Provide the original $form_id in $form_state['build_info']['form_id'], just like 'base_form_id' is provided there.
- With D7, we introduced the $form_state['build_info'] container, which holds all the build information for a form; e.g., the $args originally passed into drupal_get_form(), the base form ID in case the $form_id does not map directly to a function name and hook_forms() is invoked, etc.
- We totally forgot to record the very basic $form_id itself.
- A form constructor function is invoked directly from drupal_retrieve_form() and only gets $form and $form_state as arguments. The $form_id is not supplied anywhere.
- Only after the form has been constructed, drupal_prepare_form() adds the $form['form_id'] element to the form. Before drupal_prepare_form(), both $form and $form_state are relatively "empty".
- If a form constructor calls into other functions, then those other functions do not have a way to figure out the original $form_id, unless it was explicitly specified by the form constructor somewhere in $form or $form_state.
PASSED: [[SimpleTest]]: [MySQL] 39,267 pass(es).
PASSED: [[SimpleTest]]: [MySQL] 37,295 pass(es).
PASSED: [[SimpleTest]]: [MySQL] 39,240 pass(es).
PASSED: [[SimpleTest]]: [MySQL] 36,980 pass(es).