<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
/* SonataAdminBundle:CRUD/Association:edit_many_script.html.twig */
class __TwigTemplate_75c418601dd1e55b67125b700fa2cddccb4baff994d749c0d201f47492a13a44 extends \Twig\Template
{
private $source;
private $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
];
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "SonataAdminBundle:CRUD/Association:edit_many_script.html.twig"));
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "SonataAdminBundle:CRUD/Association:edit_many_script.html.twig"));
// line 11
echo "
";
// line 18
echo "
";
// line 20
echo "
";
// line 21
$context["associationadmin"] = twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, (isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 21, $this->source); })()), "field_description", [], "any", false, false, false, 21), "associationadmin", [], "any", false, false, false, 21);
// line 22
echo "
<!-- edit many association -->
<script type=\"text/javascript\">
";
// line 32
echo "
var field_dialog_form_list_link_";
// line 33
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 33, $this->source); })());
echo " = function(event) {
initialize_popup_";
// line 34
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 34, $this->source); })());
echo "();
var target = jQuery(this);
if (target.attr('href').length === 0 || target.attr('href') === '#') {
return;
}
event.preventDefault();
event.stopPropagation();
Admin.log('[";
// line 45
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 45, $this->source); })());
echo "|field_dialog_form_list_link] handle link click in a list');
var element = jQuery(this).parents('#field_dialog_";
// line 47
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 47, $this->source); })());
echo " .sonata-ba-list-field');
// the user does not click on a row column
if (element.length == 0) {
Admin.log('[";
// line 51
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 51, $this->source); })());
echo "|field_dialog_form_list_link] the user does not click on a row column, make ajax call to retrieve inner html');
// make a recursive call (ie: reset the filter)
jQuery.ajax({
type: 'GET',
url: jQuery(this).attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[";
// line 58
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 58, $this->source); })());
echo "|field_dialog_form_list_link] callback success, attach valid js event');
field_dialog_content_";
// line 60
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 60, $this->source); })());
echo ".html(html);
field_dialog_form_list_handle_action_";
// line 61
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 61, $this->source); })());
echo "();
Admin.shared_setup(field_dialog_";
// line 63
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 63, $this->source); })());
echo ");
}
});
return;
}
Admin.log('[";
// line 70
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 70, $this->source); })());
echo "|field_dialog_form_list_link] the user select one element, update input and hide the modal');
jQuery('#";
// line 72
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 72, $this->source); })());
echo "').val(element.attr('objectId'));
jQuery('#";
// line 73
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 73, $this->source); })());
echo "').trigger('change');
field_dialog_";
// line 75
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 75, $this->source); })());
echo ".modal('hide');
};
// this function handle action on the modal list when inside a selected list
var field_dialog_form_list_handle_action_";
// line 79
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 79, $this->source); })());
echo " = function() {
Admin.log('[";
// line 80
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 80, $this->source); })());
echo "|field_dialog_form_list_handle_action] attaching valid js event');
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery('a', field_dialog_";
// line 84
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 84, $this->source); })());
echo ").on('click', field_dialog_form_list_link_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 84, $this->source); })());
echo ");
jQuery('form', field_dialog_";
// line 85
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 85, $this->source); })());
echo ").on('submit', function(event) {
event.preventDefault();
var form = jQuery(this);
Admin.log('[";
// line 90
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 90, $this->source); })());
echo "|field_dialog_form_list_handle_action] catching submit event, sending ajax request');
jQuery(form).ajaxSubmit({
type: form.attr('method'),
url: form.attr('action'),
dataType: 'html',
data: {_xml_http_request: true},
success: function(html) {
Admin.log('[";
// line 99
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 99, $this->source); })());
echo "|field_dialog_form_list_handle_action] form submit success, restoring event');
field_dialog_content_";
// line 101
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 101, $this->source); })());
echo ".html(html);
field_dialog_form_list_handle_action_";
// line 102
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 102, $this->source); })());
echo "();
Admin.shared_setup(field_dialog_";
// line 104
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 104, $this->source); })());
echo ");
}
});
});
};
// handle the list link
var field_dialog_form_list_";
// line 111
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 111, $this->source); })());
echo " = function(event) {
initialize_popup_";
// line 113
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 113, $this->source); })());
echo "();
event.preventDefault();
event.stopPropagation();
Admin.log('[";
// line 118
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 118, $this->source); })());
echo "|field_dialog_form_list] open the list modal');
var a = jQuery(this);
field_dialog_content_";
// line 122
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 122, $this->source); })());
echo ".html('');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[";
// line 130
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 130, $this->source); })());
echo "|field_dialog_form_list] retrieving the list content');
// populate the popup container
field_dialog_content_";
// line 133
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 133, $this->source); })());
echo ".html(html);
field_dialog_title_";
// line 135
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 135, $this->source); })());
echo ".html(\"";
echo $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans(twig_get_attribute($this->env, $this->source, (isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 135, $this->source); })()), "label", [], "any", false, false, false, 135), [], twig_get_attribute($this->env, $this->source, (isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 135, $this->source); })()), "translationdomain", [], "any", false, false, false, 135));
echo "\");
Admin.shared_setup(field_dialog_";
// line 137
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 137, $this->source); })());
echo ");
field_dialog_form_list_handle_action_";
// line 139
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 139, $this->source); })());
echo "();
// open the dialog in modal mode
field_dialog_";
// line 142
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 142, $this->source); })());
echo ".modal();
Admin.setup_list_modal(field_dialog_";
// line 144
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 144, $this->source); })());
echo ");
}
});
};
// handle the add link
var field_dialog_form_add_";
// line 150
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 150, $this->source); })());
echo " = function(event) {
initialize_popup_";
// line 151
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 151, $this->source); })());
echo "();
event.preventDefault();
event.stopPropagation();
var a = jQuery(this);
field_dialog_content_";
// line 158
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 158, $this->source); })());
echo ".html('');
Admin.log('[";
// line 160
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 160, $this->source); })());
echo "|field_dialog_form_add] add link action');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[";
// line 168
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 168, $this->source); })());
echo "|field_dialog_form_add] ajax success', field_dialog_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 168, $this->source); })());
echo ");
// populate the popup container
field_dialog_content_";
// line 171
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 171, $this->source); })());
echo ".html(html);
field_dialog_title_";
// line 172
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 172, $this->source); })());
echo ".html(\"";
echo $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans(twig_get_attribute($this->env, $this->source, (isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 172, $this->source); })()), "label", [], "any", false, false, false, 172), [], twig_get_attribute($this->env, $this->source, (isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 172, $this->source); })()), "translationdomain", [], "any", false, false, false, 172));
echo "\");
Admin.shared_setup(field_dialog_";
// line 174
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 174, $this->source); })());
echo ");
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery(document).on('click','#field_dialog_";
// line 178
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 178, $this->source); })());
echo " a', field_dialog_form_action_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 178, $this->source); })());
echo ");
jQuery('form', field_dialog_";
// line 179
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 179, $this->source); })());
echo ").on('submit', field_dialog_form_action_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 179, $this->source); })());
echo ");
// open the dialog in modal mode
field_dialog_";
// line 182
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 182, $this->source); })());
echo ".modal();
Admin.setup_list_modal(field_dialog_";
// line 184
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 184, $this->source); })());
echo ");
}
});
};
// handle the edit link
var field_dialog_form_edit_";
// line 190
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 190, $this->source); })());
echo " = function(event) {
initialize_popup_";
// line 191
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 191, $this->source); })());
echo "();
event.preventDefault();
event.stopPropagation();
var a = jQuery(this);
field_dialog_content_";
// line 198
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 198, $this->source); })());
echo ".html('');
Admin.log('[";
// line 200
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 200, $this->source); })());
echo "|field_dialog_form_edit] edit link action');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[";
// line 208
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 208, $this->source); })());
echo "|field_dialog_form_edit] ajax success', field_dialog_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 208, $this->source); })());
echo ");
// populate the popup container
field_dialog_content_";
// line 211
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 211, $this->source); })());
echo ".html(html);
field_dialog_title_";
// line 212
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 212, $this->source); })());
echo ".html(\"";
echo $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans(twig_get_attribute($this->env, $this->source, (isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 212, $this->source); })()), "label", [], "any", false, false, false, 212), [], twig_get_attribute($this->env, $this->source, (isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 212, $this->source); })()), "translationdomain", [], "any", false, false, false, 212));
echo "\");
Admin.shared_setup(field_dialog_";
// line 214
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 214, $this->source); })());
echo ");
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery(document).on('click','#field_dialog_";
// line 218
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 218, $this->source); })());
echo " a', field_dialog_form_action_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 218, $this->source); })());
echo ");
jQuery('form', field_dialog_";
// line 219
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 219, $this->source); })());
echo ").on('submit', field_dialog_form_action_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 219, $this->source); })());
echo ");
// open the dialog in modal mode
field_dialog_";
// line 222
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 222, $this->source); })());
echo ".modal();
Admin.setup_list_modal(field_dialog_";
// line 224
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 224, $this->source); })());
echo ");
}
});
};
// handle the post data
var field_dialog_form_action_";
// line 230
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 230, $this->source); })());
echo " = function(event) {
var element = jQuery(this);
// return if the link is an anchor inside the same page
if (
this.nodeName === 'A'
&& (
element.attr('href').length === 0
|| element.attr('href')[0] === '#'
|| element.attr('href').substr(0, 11) === 'javascript:'
)
) {
Admin.log('[";
// line 243
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 243, $this->source); })());
echo "|field_dialog_form_action] element is an anchor or a script, skipping action', this);
return;
}
event.preventDefault();
event.stopPropagation();
Admin.log('[";
// line 250
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 250, $this->source); })());
echo "|field_dialog_form_action] action catch', this);
initialize_popup_";
// line 252
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 252, $this->source); })());
echo "();
if (this.nodeName == 'FORM') {
var url = element.attr('action');
var type = element.attr('method');
} else if (this.nodeName == 'A') {
var url = element.attr('href');
var type = 'GET';
} else {
alert('unexpected element : @' + this.nodeName + '@');
return;
}
if (element.hasClass('sonata-ba-action')) {
Admin.log('[";
// line 266
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 266, $this->source); })());
echo "|field_dialog_form_action] reserved action stop catch all events');
return;
}
var data = {
_xml_http_request: true
}
var form = jQuery(this);
Admin.log('[";
// line 276
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 276, $this->source); })());
echo "|field_dialog_form_action] execute ajax call');
// the ajax post
jQuery(form).ajaxSubmit({
url: url,
type: type,
data: data,
success: function(data) {
Admin.log('[";
// line 284
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 284, $this->source); })());
echo "|field_dialog_form_action] ajax success');
// 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 (typeof data != 'string' && data.result == 'ok') {
field_dialog_";
// line 289
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 289, $this->source); })());
echo ".modal('hide');
";
// line 291
if ((twig_get_attribute($this->env, $this->source, (isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 291, $this->source); })()), "edit", [], "any", false, false, false, 291) == "list")) {
// line 292
echo " ";
// line 296
echo " jQuery('#";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 296, $this->source); })());
echo "').val(data.objectId);
jQuery('#";
// line 297
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 297, $this->source); })());
echo "').change();
";
} else {
// line 300
echo "
// reload the form element
jQuery('#field_widget_";
// line 302
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 302, $this->source); })());
echo "').closest('form').ajaxSubmit({
url: '";
// line 303
echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("sonata_admin_retrieve_form_element", ["elementId" => // line 304
(isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 304, $this->source); })()), "subclass" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, // line 305
(isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 305, $this->source); })()), "admin", [], "any", false, false, false, 305), "getActiveSubclassCode", [], "method", false, false, false, 305), "objectId" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, // line 306
(isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 306, $this->source); })()), "admin", [], "any", false, false, false, 306), "root", [], "any", false, false, false, 306), "id", [0 => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, (isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 306, $this->source); })()), "admin", [], "any", false, false, false, 306), "root", [], "any", false, false, false, 306), "subject", [], "any", false, false, false, 306)], "method", false, false, false, 306), "uniqid" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, // line 307
(isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 307, $this->source); })()), "admin", [], "any", false, false, false, 307), "root", [], "any", false, false, false, 307), "uniqid", [], "any", false, false, false, 307), "code" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, // line 308
(isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 308, $this->source); })()), "admin", [], "any", false, false, false, 308), "root", [], "any", false, false, false, 308), "code", [], "any", false, false, false, 308)]);
// line 309
echo "',
data: {_xml_http_request: true },
dataType: 'html',
type: 'POST',
success: function(html) {
jQuery('#field_container_";
// line 314
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 314, $this->source); })());
echo "').replaceWith(html);
var newElement = jQuery('#";
// line 315
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 315, $this->source); })());
echo " [value=\"' + data.objectId + '\"]');
if (newElement.is(\"input\")) {
newElement.attr('checked', 'checked');
} else {
newElement.attr('selected', 'selected');
}
jQuery('#field_container_";
// line 322
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 322, $this->source); })());
echo "').trigger('sonata-admin-append-form-element');
}
});
";
}
// line 327
echo "
return;
}
// otherwise, display form error
field_dialog_content_";
// line 332
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 332, $this->source); })());
echo ".html(data);
Admin.shared_setup(field_dialog_";
// line 334
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 334, $this->source); })());
echo ");
// reattach the event
jQuery('form', field_dialog_";
// line 337
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 337, $this->source); })());
echo ").submit(field_dialog_form_action_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 337, $this->source); })());
echo ");
}
});
return false;
};
var field_dialog_";
// line 344
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 344, $this->source); })());
echo " = false;
var field_dialog_content_";
// line 345
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 345, $this->source); })());
echo " = false;
var field_dialog_title_";
// line 346
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 346, $this->source); })());
echo " = false;
function initialize_popup_";
// line 348
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 348, $this->source); })());
echo "() {
// initialize component
if (!field_dialog_";
// line 350
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 350, $this->source); })());
echo ") {
field_dialog_";
// line 351
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 351, $this->source); })());
echo " = jQuery(\"#field_dialog_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 351, $this->source); })());
echo "\");
field_dialog_content_";
// line 352
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 352, $this->source); })());
echo " = jQuery(\".modal-body\", \"#field_dialog_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 352, $this->source); })());
echo "\");
field_dialog_title_";
// line 353
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 353, $this->source); })());
echo " = jQuery(\".modal-title\", \"#field_dialog_";
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 353, $this->source); })());
echo "\");
// move the dialog as a child of the root element, nested form breaks html ...
jQuery(document.body).append(field_dialog_";
// line 356
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 356, $this->source); })());
echo ");
Admin.log('[";
// line 358
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 358, $this->source); })());
echo "|field_dialog] move dialog container as a document child');
}
}
";
// line 365
echo " // this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_dialog_form_add_";
// line 367
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 367, $this->source); })());
echo "(link) {
// remove the html event
link.onclick = null;
initialize_popup_";
// line 372
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 372, $this->source); })());
echo "();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_add_";
// line 376
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 376, $this->source); })());
echo ")
.trigger('click')
;
return false;
}
";
// line 386
echo " // this function initializes the popup
// this can only be done this way as popup can be cascaded
function start_field_dialog_form_edit_";
// line 388
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 388, $this->source); })());
echo "(link) {
// remove the html event
link.onclick = null;
initialize_popup_";
// line 393
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 393, $this->source); })());
echo "();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_edit_";
// line 397
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 397, $this->source); })());
echo ")
.trigger('click')
;
return false;
}
if (field_dialog_";
// line 404
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 404, $this->source); })());
echo ") {
Admin.shared_setup(field_dialog_";
// line 405
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 405, $this->source); })());
echo ");
}
";
// line 408
if ((twig_get_attribute($this->env, $this->source, (isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 408, $this->source); })()), "edit", [], "any", false, false, false, 408) == "list")) {
// line 409
echo " ";
// line 412
echo " // this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_dialog_form_list_";
// line 414
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 414, $this->source); })());
echo "(link) {
link.onclick = null;
initialize_popup_";
// line 418
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 418, $this->source); })());
echo "();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_list_";
// line 422
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 422, $this->source); })());
echo ")
.trigger('click')
;
return false;
}
function remove_selected_element_";
// line 429
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 429, $this->source); })());
echo "(link) {
link.onclick = null;
jQuery(link)
.click(field_remove_element_";
// line 434
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 434, $this->source); })());
echo ")
.trigger('click')
;
return false;
}
function field_remove_element_";
// line 441
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 441, $this->source); })());
echo "(event) {
event.preventDefault();
if (jQuery('#";
// line 444
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 444, $this->source); })());
echo " option').get(0)) {
jQuery('#";
// line 445
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 445, $this->source); })());
echo "').attr('selectedIndex', '-1').children(\"option:selected\").attr(\"selected\", false);
}
jQuery('#";
// line 448
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 448, $this->source); })());
echo "').val('');
jQuery('#";
// line 449
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 449, $this->source); })());
echo "').trigger('change');
return false;
}
";
// line 456
echo "
// update the label
jQuery('#";
// line 458
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 458, $this->source); })());
echo "').on('change', function(event) {
Admin.log('[";
// line 460
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 460, $this->source); })());
echo "|on:change] update the label');
jQuery('#field_widget_";
// line 462
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 462, $this->source); })());
echo "').html(\"<span><img src=\\\"";
echo $this->extensions['Symfony\Bridge\Twig\Extension\AssetExtension']->getAssetUrl("bundles/sonataadmin/ajax-loader.gif");
echo "\\\" style=\\\"vertical-align: middle; margin-right: 10px\\\"/>";
echo $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("loading_information", [], "SonataAdminBundle");
echo "</span>\");
jQuery.ajax({
type: 'GET',
url: '";
// line 465
echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("sonata_admin_short_object_information", ["objectId" => "OBJECT_ID", "uniqid" => twig_get_attribute($this->env, $this->source, // line 467
(isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 467, $this->source); })()), "uniqid", [], "any", false, false, false, 467), "code" => twig_get_attribute($this->env, $this->source, // line 468
(isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 468, $this->source); })()), "code", [], "any", false, false, false, 468), "linkParameters" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, // line 469
(isset($context["sonata_admin"]) || array_key_exists("sonata_admin", $context) ? $context["sonata_admin"] : (function () { throw new RuntimeError('Variable "sonata_admin" does not exist.', 469, $this->source); })()), "field_description", [], "any", false, false, false, 469), "options", [], "any", false, false, false, 469), "link_parameters", [], "any", false, false, false, 469)]);
// line 470
echo "'.replace('OBJECT_ID', jQuery(this).val()),
dataType: 'html',
success: function(html) {
jQuery('#field_widget_";
// line 473
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 473, $this->source); })());
echo "').html(html);
}
});
";
// line 477
if ((isset($context["btn_edit"]) || array_key_exists("btn_edit", $context) ? $context["btn_edit"] : (function () { throw new RuntimeError('Variable "btn_edit" does not exist.', 477, $this->source); })())) {
// line 478
echo " var edit_button_url = '";
echo twig_get_attribute($this->env, $this->source, // line 479
(isset($context["associationadmin"]) || array_key_exists("associationadmin", $context) ? $context["associationadmin"] : (function () { throw new RuntimeError('Variable "associationadmin" does not exist.', 479, $this->source); })()), "generateUrl", [0 => "edit", 1 => ["id" => "OBJECT_ID"]], "method", false, false, false, 479);
// line 480
echo "'.replace('OBJECT_ID', jQuery(this).val());
var edit_button_node = jQuery('#field_actions_";
// line 482
echo (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 482, $this->source); })());
echo " a.btn-warning');
if (jQuery(this).val()) {
edit_button_node.removeClass('hidden').attr('href', edit_button_url);
} else {
edit_button_node.addClass('hidden');
}
";
}
// line 489
echo " });
";
}
// line 492
echo "
</script>
<!-- / edit many association -->
";
$__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);
$__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);
}
public function getTemplateName()
{
return "SonataAdminBundle:CRUD/Association:edit_many_script.html.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
{
return array ( 892 => 492, 887 => 489, 877 => 482, 873 => 480, 871 => 479, 869 => 478, 867 => 477, 860 => 473, 855 => 470, 853 => 469, 852 => 468, 851 => 467, 850 => 465, 840 => 462, 835 => 460, 830 => 458, 826 => 456, 819 => 449, 815 => 448, 809 => 445, 805 => 444, 799 => 441, 789 => 434, 781 => 429, 771 => 422, 764 => 418, 757 => 414, 753 => 412, 751 => 409, 749 => 408, 743 => 405, 739 => 404, 729 => 397, 722 => 393, 714 => 388, 710 => 386, 700 => 376, 693 => 372, 685 => 367, 681 => 365, 674 => 358, 669 => 356, 661 => 353, 655 => 352, 649 => 351, 645 => 350, 640 => 348, 635 => 346, 631 => 345, 627 => 344, 615 => 337, 609 => 334, 604 => 332, 597 => 327, 589 => 322, 579 => 315, 575 => 314, 568 => 309, 566 => 308, 565 => 307, 564 => 306, 563 => 305, 562 => 304, 561 => 303, 557 => 302, 553 => 300, 547 => 297, 542 => 296, 540 => 292, 538 => 291, 533 => 289, 525 => 284, 514 => 276, 501 => 266, 484 => 252, 479 => 250, 469 => 243, 453 => 230, 444 => 224, 439 => 222, 431 => 219, 425 => 218, 418 => 214, 411 => 212, 407 => 211, 399 => 208, 388 => 200, 383 => 198, 373 => 191, 369 => 190, 360 => 184, 355 => 182, 347 => 179, 341 => 178, 334 => 174, 327 => 172, 323 => 171, 315 => 168, 304 => 160, 299 => 158, 289 => 151, 285 => 150, 276 => 144, 271 => 142, 265 => 139, 260 => 137, 253 => 135, 248 => 133, 242 => 130, 231 => 122, 224 => 118, 216 => 113, 211 => 111, 201 => 104, 196 => 102, 192 => 101, 187 => 99, 175 => 90, 167 => 85, 161 => 84, 154 => 80, 150 => 79, 143 => 75, 138 => 73, 134 => 72, 129 => 70, 119 => 63, 114 => 61, 110 => 60, 105 => 58, 95 => 51, 88 => 47, 83 => 45, 69 => 34, 65 => 33, 62 => 32, 55 => 22, 53 => 21, 50 => 20, 47 => 18, 43 => 11,);
}
public function getSourceContext()
{
return new Source("{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{#
This code manages the many-to-[one|many] association field popup
#}
{% autoescape false %}
{% set associationadmin = sonata_admin.field_description.associationadmin %}
<!-- edit many association -->
<script type=\"text/javascript\">
{#
handle link click in a list :
- if the parent has an objectId defined then the related input get updated
- if the parent has NO object then an ajax request is made to refresh the popup
#}
var field_dialog_form_list_link_{{ id }} = function(event) {
initialize_popup_{{ id }}();
var target = jQuery(this);
if (target.attr('href').length === 0 || target.attr('href') === '#') {
return;
}
event.preventDefault();
event.stopPropagation();
Admin.log('[{{ id }}|field_dialog_form_list_link] handle link click in a list');
var element = jQuery(this).parents('#field_dialog_{{ id }} .sonata-ba-list-field');
// the user does not click on a row column
if (element.length == 0) {
Admin.log('[{{ id }}|field_dialog_form_list_link] the user does not click on a row column, make ajax call to retrieve inner html');
// make a recursive call (ie: reset the filter)
jQuery.ajax({
type: 'GET',
url: jQuery(this).attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_list_link] callback success, attach valid js event');
field_dialog_content_{{ id }}.html(html);
field_dialog_form_list_handle_action_{{ id }}();
Admin.shared_setup(field_dialog_{{ id }});
}
});
return;
}
Admin.log('[{{ id }}|field_dialog_form_list_link] the user select one element, update input and hide the modal');
jQuery('#{{ id }}').val(element.attr('objectId'));
jQuery('#{{ id }}').trigger('change');
field_dialog_{{ id }}.modal('hide');
};
// this function handle action on the modal list when inside a selected list
var field_dialog_form_list_handle_action_{{ id }} = function() {
Admin.log('[{{ id }}|field_dialog_form_list_handle_action] attaching valid js event');
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery('a', field_dialog_{{ id }}).on('click', field_dialog_form_list_link_{{ id }});
jQuery('form', field_dialog_{{ id }}).on('submit', function(event) {
event.preventDefault();
var form = jQuery(this);
Admin.log('[{{ id }}|field_dialog_form_list_handle_action] catching submit event, sending ajax request');
jQuery(form).ajaxSubmit({
type: form.attr('method'),
url: form.attr('action'),
dataType: 'html',
data: {_xml_http_request: true},
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_list_handle_action] form submit success, restoring event');
field_dialog_content_{{ id }}.html(html);
field_dialog_form_list_handle_action_{{ id }}();
Admin.shared_setup(field_dialog_{{ id }});
}
});
});
};
// handle the list link
var field_dialog_form_list_{{ id }} = function(event) {
initialize_popup_{{ id }}();
event.preventDefault();
event.stopPropagation();
Admin.log('[{{ id }}|field_dialog_form_list] open the list modal');
var a = jQuery(this);
field_dialog_content_{{ id }}.html('');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_list] retrieving the list content');
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html(\"{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}\");
Admin.shared_setup(field_dialog_{{ id }});
field_dialog_form_list_handle_action_{{ id }}();
// open the dialog in modal mode
field_dialog_{{ id }}.modal();
Admin.setup_list_modal(field_dialog_{{ id }});
}
});
};
// handle the add link
var field_dialog_form_add_{{ id }} = function(event) {
initialize_popup_{{ id }}();
event.preventDefault();
event.stopPropagation();
var a = jQuery(this);
field_dialog_content_{{ id }}.html('');
Admin.log('[{{ id }}|field_dialog_form_add] add link action');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_add] ajax success', field_dialog_{{ id }});
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html(\"{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}\");
Admin.shared_setup(field_dialog_{{ id }});
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery(document).on('click','#field_dialog_{{ id }} a', field_dialog_form_action_{{ id }});
jQuery('form', field_dialog_{{ id }}).on('submit', field_dialog_form_action_{{ id }});
// open the dialog in modal mode
field_dialog_{{ id }}.modal();
Admin.setup_list_modal(field_dialog_{{ id }});
}
});
};
// handle the edit link
var field_dialog_form_edit_{{ id }} = function(event) {
initialize_popup_{{ id }}();
event.preventDefault();
event.stopPropagation();
var a = jQuery(this);
field_dialog_content_{{ id }}.html('');
Admin.log('[{{ id }}|field_dialog_form_edit] edit link action');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_edit] ajax success', field_dialog_{{ id }});
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html(\"{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}\");
Admin.shared_setup(field_dialog_{{ id }});
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery(document).on('click','#field_dialog_{{ id }} a', field_dialog_form_action_{{ id }});
jQuery('form', field_dialog_{{ id }}).on('submit', field_dialog_form_action_{{ id }});
// open the dialog in modal mode
field_dialog_{{ id }}.modal();
Admin.setup_list_modal(field_dialog_{{ id }});
}
});
};
// handle the post data
var field_dialog_form_action_{{ id }} = function(event) {
var element = jQuery(this);
// return if the link is an anchor inside the same page
if (
this.nodeName === 'A'
&& (
element.attr('href').length === 0
|| element.attr('href')[0] === '#'
|| element.attr('href').substr(0, 11) === 'javascript:'
)
) {
Admin.log('[{{ id }}|field_dialog_form_action] element is an anchor or a script, skipping action', this);
return;
}
event.preventDefault();
event.stopPropagation();
Admin.log('[{{ id }}|field_dialog_form_action] action catch', this);
initialize_popup_{{ id }}();
if (this.nodeName == 'FORM') {
var url = element.attr('action');
var type = element.attr('method');
} else if (this.nodeName == 'A') {
var url = element.attr('href');
var type = 'GET';
} else {
alert('unexpected element : @' + this.nodeName + '@');
return;
}
if (element.hasClass('sonata-ba-action')) {
Admin.log('[{{ id }}|field_dialog_form_action] reserved action stop catch all events');
return;
}
var data = {
_xml_http_request: true
}
var form = jQuery(this);
Admin.log('[{{ id }}|field_dialog_form_action] execute ajax call');
// the ajax post
jQuery(form).ajaxSubmit({
url: url,
type: type,
data: data,
success: function(data) {
Admin.log('[{{ id }}|field_dialog_form_action] ajax success');
// 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 (typeof data != 'string' && data.result == 'ok') {
field_dialog_{{ id }}.modal('hide');
{% if sonata_admin.edit == 'list' %}
{#
in this case we update the hidden input, and call the change event to
retrieve the post information
#}
jQuery('#{{ id }}').val(data.objectId);
jQuery('#{{ id }}').change();
{% else %}
// reload the form element
jQuery('#field_widget_{{ id }}').closest('form').ajaxSubmit({
url: '{{ path('sonata_admin_retrieve_form_element', {
'elementId': id,
'subclass': sonata_admin.admin.getActiveSubclassCode(),
'objectId': sonata_admin.admin.root.id(sonata_admin.admin.root.subject),
'uniqid': sonata_admin.admin.root.uniqid,
'code': sonata_admin.admin.root.code
}) }}',
data: {_xml_http_request: true },
dataType: 'html',
type: 'POST',
success: function(html) {
jQuery('#field_container_{{ id }}').replaceWith(html);
var newElement = jQuery('#{{ id }} [value=\"' + data.objectId + '\"]');
if (newElement.is(\"input\")) {
newElement.attr('checked', 'checked');
} else {
newElement.attr('selected', 'selected');
}
jQuery('#field_container_{{ id }}').trigger('sonata-admin-append-form-element');
}
});
{% endif %}
return;
}
// otherwise, display form error
field_dialog_content_{{ id }}.html(data);
Admin.shared_setup(field_dialog_{{ id }});
// reattach the event
jQuery('form', field_dialog_{{ id }}).submit(field_dialog_form_action_{{ id }});
}
});
return false;
};
var field_dialog_{{ id }} = false;
var field_dialog_content_{{ id }} = false;
var field_dialog_title_{{ id }} = false;
function initialize_popup_{{ id }}() {
// initialize component
if (!field_dialog_{{ id }}) {
field_dialog_{{ id }} = jQuery(\"#field_dialog_{{ id }}\");
field_dialog_content_{{ id }} = jQuery(\".modal-body\", \"#field_dialog_{{ id }}\");
field_dialog_title_{{ id }} = jQuery(\".modal-title\", \"#field_dialog_{{ id }}\");
// move the dialog as a child of the root element, nested form breaks html ...
jQuery(document.body).append(field_dialog_{{ id }});
Admin.log('[{{ id }}|field_dialog] move dialog container as a document child');
}
}
{#
This code is used to define the \"add\" popup
#}
// this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_dialog_form_add_{{ id }}(link) {
// remove the html event
link.onclick = null;
initialize_popup_{{ id }}();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_add_{{ id }})
.trigger('click')
;
return false;
}
{#
This code is used to define the \"edit\" popup
#}
// this function initializes the popup
// this can only be done this way as popup can be cascaded
function start_field_dialog_form_edit_{{ id }}(link) {
// remove the html event
link.onclick = null;
initialize_popup_{{ id }}();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_edit_{{ id }})
.trigger('click')
;
return false;
}
if (field_dialog_{{ id }}) {
Admin.shared_setup(field_dialog_{{ id }});
}
{% if sonata_admin.edit == 'list' %}
{#
This code is used to defined the \"list\" popup
#}
// this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_dialog_form_list_{{ id }}(link) {
link.onclick = null;
initialize_popup_{{ id }}();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_list_{{ id }})
.trigger('click')
;
return false;
}
function remove_selected_element_{{ id }}(link) {
link.onclick = null;
jQuery(link)
.click(field_remove_element_{{ id }})
.trigger('click')
;
return false;
}
function field_remove_element_{{ id }}(event) {
event.preventDefault();
if (jQuery('#{{ id }} option').get(0)) {
jQuery('#{{ id }}').attr('selectedIndex', '-1').children(\"option:selected\").attr(\"selected\", false);
}
jQuery('#{{ id }}').val('');
jQuery('#{{ id }}').trigger('change');
return false;
}
{#
attach onchange event on the input
#}
// update the label
jQuery('#{{ id }}').on('change', function(event) {
Admin.log('[{{ id }}|on:change] update the label');
jQuery('#field_widget_{{ id }}').html(\"<span><img src=\\\"{{ asset('bundles/sonataadmin/ajax-loader.gif') }}\\\" style=\\\"vertical-align: middle; margin-right: 10px\\\"/>{{ 'loading_information'|trans([], 'SonataAdminBundle') }}</span>\");
jQuery.ajax({
type: 'GET',
url: '{{ path('sonata_admin_short_object_information', {
'objectId': 'OBJECT_ID',
'uniqid': associationadmin.uniqid,
'code': associationadmin.code,
'linkParameters': sonata_admin.field_description.options.link_parameters
})}}'.replace('OBJECT_ID', jQuery(this).val()),
dataType: 'html',
success: function(html) {
jQuery('#field_widget_{{ id }}').html(html);
}
});
{% if btn_edit %}
var edit_button_url = '{{
associationadmin.generateUrl('edit', {'id' : 'OBJECT_ID'})
}}'.replace('OBJECT_ID', jQuery(this).val());
var edit_button_node = jQuery('#field_actions_{{ id }} a.btn-warning');
if (jQuery(this).val()) {
edit_button_node.removeClass('hidden').attr('href', edit_button_url);
} else {
edit_button_node.addClass('hidden');
}
{% endif %}
});
{% endif %}
</script>
<!-- / edit many association -->
{% endautoescape %}
", "SonataAdminBundle:CRUD/Association:edit_many_script.html.twig", "/var/www/radmin.tehnik.tech/vendor/sonata-project/admin-bundle/src/Resources/views/CRUD/Association/edit_many_script.html.twig");
}
}