summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitaibu2013-02-12 11:40:45 (GMT)
committer Amitaibu2013-02-12 11:40:45 (GMT)
commit1c39b787d105b6124896035def6e9e408cd8905f (patch)
tree3d417f96448a51437c7ceede38ca134ee13ef494
parent726c8ef00d3d8b023cb5b412eecd0b3339ece488 (diff)
Issue #1502972 by a.ross, MEsch, Amitaibu, ezheidtmann, ndeschildre, kpv, Angry Dan | heylookalive: Fixed Issues with ajax file upload fields.
-rw-r--r--entityreference_prepopulate.module30
1 files changed, 22 insertions, 8 deletions
diff --git a/entityreference_prepopulate.module b/entityreference_prepopulate.module
index b6346c6..2747ee4 100644
--- a/entityreference_prepopulate.module
+++ b/entityreference_prepopulate.module
@@ -128,7 +128,14 @@ function entityreference_prepopulate_field_attach_form($entity_type, $entity, &$
}
$field = $value['field'];
- if (entityreference_prepopulate_get_values($field, $instance) || ($id && !empty($settings['action_on_edit']))) {
+
+ // Store prepopulated values in the form state to make them persistent,
+ // in case the form is rebuilt by AJAX requests.
+ if ($values = entityreference_prepopulate_get_values($field, $instance)) {
+ $form_state['entityreference_prepopulate'][$instance['entity_type']][$instance['bundle']][$field['field_name']] = $values;
+ }
+
+ if ($values || ($id && !empty($settings['action_on_edit']))) {
// New entity with prepopualte values, or an existing entity,
// we might need to disable/ hide the group-audience field.
if ($settings['action'] == 'disable') {
@@ -249,17 +256,24 @@ function entityreference_prepopulate_get_values_from_url($field, $instance, $fla
if (isset($cache[$identifier])) {
return $cache[$identifier];
}
- $cache[$identifier] = FALSE;
- if (empty($_GET[$field_name]) || !is_string($_GET[$field_name])) {
- return;
+ // Check to see if we cached the values in a $form_state object (and we are
+ // refreshing the form)
+ $form_build_id = isset($_GET['form_build_id']) ? $_GET['form_build_id'] : isset($_POST['form_build_id']) ? $_POST['form_build_id'] : NULL;
+ if (!empty($form_build_id)) {
+ $form_state = array();
+ $form = form_get_cache($form_build_id, $form_state);
+ if (isset($form_state['entityreference_prepopulate'][$instance['entity_type']][$instance['bundle']][$field_name])) {
+ $ids = $form_state['entityreference_prepopulate'][$instance['entity_type']][$instance['bundle']][$field_name];
+ }
}
-
- if (empty($instance['settings']['behaviors']['prepopulate']['status'])) {
+ elseif (empty($_GET[$field_name]) || !is_string($_GET[$field_name]) || empty($instance['settings']['behaviors']['prepopulate']['status'])) {
+ $cache[$identifier] = FALSE;
return;
}
-
- $ids = explode(',', $_GET[$field_name]);
+ else {
+ $ids = explode(',', $_GET[$field_name]);
+ }
// Check if the IDs are valid, and get filter out the ones that are not valid.
$handler = entityreference_get_selection_handler($field, $instance);