summaryrefslogtreecommitdiff
path: root/modules/field/field.form.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-05-03 09:49:32 +0000
committerDries Buytaert <dries@buytaert.net>2009-05-03 09:49:32 +0000
commit3d951475eaebab990a78d07acdc344eb50239e18 (patch)
treea004edfe21ff13b45baf33362219200081e52ee8 /modules/field/field.form.inc
parent8c7fd11fd4b447e3bd47be782afa56a4109a222b (diff)
downloadbrdo-3d951475eaebab990a78d07acdc344eb50239e18.tar.gz
brdo-3d951475eaebab990a78d07acdc344eb50239e18.tar.bz2
- Patch #402264 by yched, bjaspan: adapt field's add-more js handler to recent fapi changes. Added tests.
Diffstat (limited to 'modules/field/field.form.inc')
-rw-r--r--modules/field/field.form.inc15
1 files changed, 6 insertions, 9 deletions
diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc
index 234eb69c2..bc7b1426d 100644
--- a/modules/field/field.form.inc
+++ b/modules/field/field.form.inc
@@ -184,7 +184,7 @@ function field_multiple_value_form($field, $instance, $items, &$form, &$form_sta
}
// Add AHAH add more button, if not working with a programmed form.
- if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form['#programmed'])) {
+ if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
// Make sure the form is cached so ahah can work.
$form['#cache'] = TRUE;
$bundle_name_url_str = str_replace('_', '-', $instance['bundle']);
@@ -351,7 +351,7 @@ function field_add_more_js($bundle_name, $field_name) {
}
// Retrieve the cached form.
- $form_state = array('submitted' => FALSE);
+ $form_state = form_state_defaults();
$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
if (!$form) {
@@ -387,7 +387,7 @@ function field_add_more_js($bundle_name, $field_name) {
// $form_state, so we use copies of $form and $form_state.
$form_copy = $form;
$form_state_copy = $form_state;
- $form_copy['#post'] = array();
+ $form_state_copy['input'] = array();
form_builder($_POST['form_id'], $form_copy, $form_state_copy);
// Just grab the data we need.
$form_state['values'] = $form_state_copy['values'];
@@ -425,15 +425,12 @@ function field_add_more_js($bundle_name, $field_name) {
// render the new element.
$delta = max(array_keys($_POST[$field_name])) + 1;
$_POST[$field_name][$delta]['_weight'] = $delta;
- $form_state = array('submitted' => FALSE);
- $form += array(
- '#post' => $_POST,
- '#programmed' => FALSE,
- );
+ $form_state = form_state_defaults();
+ $form_state['input'] = $_POST;
$form = form_builder($_POST['form_id'], $form, $form_state);
// Render the new output.
- // We get fetch the form element from the built $form.
+ // We fetch the form element from the built $form.
$field_form = $form;
foreach ($form_path as $key) {
$field_form = $field_form[$key];