summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Sorqvist2013-01-19 15:58:26 (GMT)
committer Fabian Sorqvist2013-01-19 15:58:26 (GMT)
commit759907917052b8094f42c61b789721b6a985df95 (patch)
tree37c8765cd53dad8d81767b855f9d7dbca59f5fca
parent5ffcf2de46456572b9c81679300e26c9b742e180 (diff)
Rewrite ief form to use ajax properly
-rw-r--r--entity_collection.ief.inc22
1 files changed, 16 insertions, 6 deletions
diff --git a/entity_collection.ief.inc b/entity_collection.ief.inc
index 3327c01..72b18eb 100644
--- a/entity_collection.ief.inc
+++ b/entity_collection.ief.inc
@@ -121,18 +121,28 @@ function entity_collection_ief_create_form($form, EntityCollection $entity_colle
* If we are going to use with JS or not. JSON will be returned if it's true.
*/
function entity_collection_ief_add(EntityCollection $entity_collection, $entity_type, $entity_bundle, $js) {
- $form = drupal_get_form('entity_collection_ief_form', $entity_collection, $entity_type, $entity_bundle);
if (!$js) {
- return $form;
+ return drupal_get_form('entity_collection_ief_form', $entity_collection, $entity_type, $entity_bundle);
}
$entity_info = entity_get_info($entity_type);
ctools_include('modal');
ctools_include('ajax');
- $commands = array();
- $commands[] = ctools_modal_command_display($entity_info['bundles'][$entity_bundle]['label'], $form);
- $commands[] = ctools_modal_command_loading();
- if (!empty($_GET['dismiss'])) {
+ $form_state = array(
+ 'ajax' => TRUE,
+ 'title' => 'My title',
+ 'build_info' => array(
+ 'args' => array(
+ $entity_collection,
+ $entity_type,
+ $entity_bundle,
+ ),
+ ),
+ );
+ $commands = ctools_modal_form_wrapper('entity_collection_ief_form', $form_state);
+ if (!empty($form_state['executed'])) {
+ $commands = array();
$commands[] = ctools_modal_command_dismiss();
+ $commands[] = ctools_ajax_command_reload();
}
print ajax_render($commands);
exit();