Skip to content
Snippets Groups Projects
Commit 8a10f3ea authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#181328: pass on whole form to #process functions to enable advanced form...

#181328: pass on whole form to #process functions to enable advanced form handling (such as required by some CCK widgets)
parent 79641f53
No related branches found
No related tags found
No related merge requests found
...@@ -716,6 +716,8 @@ function form_error(&$element, $message = '') { ...@@ -716,6 +716,8 @@ function form_error(&$element, $message = '') {
* $_POST data. * $_POST data.
*/ */
function form_builder($form_id, $form, &$form_state) { function form_builder($form_id, $form, &$form_state) {
static $complete_form;
// Initialize as unprocessed. // Initialize as unprocessed.
$form['#processed'] = FALSE; $form['#processed'] = FALSE;
...@@ -725,12 +727,15 @@ function form_builder($form_id, $form, &$form_state) { ...@@ -725,12 +727,15 @@ function form_builder($form_id, $form, &$form_state) {
$form += $info; $form += $info;
} }
if (isset($form['#type']) && $form['#type'] == 'form' && !empty($form['#programmed'])) { if (isset($form['#type']) && $form['#type'] == 'form') {
$form_state['submitted'] = TRUE; $complete_form = $form;
if (!empty($form['#programmed'])) {
$form_state['submitted'] = TRUE;
}
} }
if (isset($form['#input']) && $form['#input']) { if (isset($form['#input']) && $form['#input']) {
_form_builder_handle_input_element($form_id, $form, $form_state); _form_builder_handle_input_element($form_id, $form, $form_state, $complete_form);
} }
$form['#defaults_loaded'] = TRUE; $form['#defaults_loaded'] = TRUE;
...@@ -796,7 +801,7 @@ function form_builder($form_id, $form, &$form_state) { ...@@ -796,7 +801,7 @@ function form_builder($form_id, $form, &$form_state) {
* can be processed and rendered. Also, execute any #process handlers * can be processed and rendered. Also, execute any #process handlers
* attached to a specific element. * attached to a specific element.
*/ */
function _form_builder_handle_input_element($form_id, &$form, &$form_state) { function _form_builder_handle_input_element($form_id, &$form, &$form_state, $complete_form) {
if (!isset($form['#name'])) { if (!isset($form['#name'])) {
$name = array_shift($form['#parents']); $name = array_shift($form['#parents']);
$form['#name'] = $name; $form['#name'] = $name;
...@@ -886,7 +891,7 @@ function _form_builder_handle_input_element($form_id, &$form, &$form_state) { ...@@ -886,7 +891,7 @@ function _form_builder_handle_input_element($form_id, &$form, &$form_state) {
if (isset($form['#process']) && !$form['#processed']) { if (isset($form['#process']) && !$form['#processed']) {
foreach ($form['#process'] as $process) { foreach ($form['#process'] as $process) {
if (function_exists($process)) { if (function_exists($process)) {
$args = array_merge(array($form), array(isset($edit) ? $edit : NULL), array($form_state)); $args = array_merge(array($form), array(isset($edit) ? $edit : NULL), array($form_state), array($complete_form));
$form = call_user_func_array($process, $args); $form = call_user_func_array($process, $args);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment