Skip to content

Commit

Permalink
Merge pull request #128 from spolischook/fixed-field-dialog-form-acti…
Browse files Browse the repository at this point in the history
…on-ajax-call

Fixed field_dialog_form_action
  • Loading branch information
dunglas committed Oct 14, 2014
2 parents bd34a3b + 2287de5 commit 499fb03
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Resources/views/CRUD/edit_mongo_association_script.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ This code manage the many-to-[one|many] association field popup
Admin.log('[{{ id }}|field_dialog_form_action] execute ajax call');
// the ajax post
jQuery(form).ajaxSubmit({
url: url,
Expand All @@ -244,14 +245,9 @@ This code manage the many-to-[one|many] association field popup
Admin.log('[{{ id }}|field_dialog_form_action] ajax success');
if (typeof data == 'string') {
field_dialog_{{ id }}.html(data);
return;
};
// if the crud action return ok, then the element has been added
// so the widget container must be refresh with the last option available
if (data.result == 'ok') {
if (typeof data != 'string' && data.result == 'ok') {
field_dialog_{{ id }}.dialog('close');
{% if sonata_admin.edit == 'list' %}
Expand Down Expand Up @@ -295,12 +291,15 @@ This code manage the many-to-[one|many] association field popup
}
// otherwise, display form error
field_dialog_{{ id }}.html(html);
field_dialog_{{ id }}.html(data);
Admin.add_pretty_errors(field_dialog_{{ id }});
// reattach the event
jQuery('form', field_dialog_{{ id }}).submit(field_dialog_form_action_{{ id }});
}, error: function(jqXHR, textStatus, errorThrown) {
Admin.log('[{{ id }}|field_dialog_form_action] Status: ' + textStatus);
Admin.log('[{{ id }}|field_dialog_form_action] Error: ' + errorThrown);
}
});
Expand Down

0 comments on commit 499fb03

Please sign in to comment.