Erreur Symfony2 - An exception has been thrown

Fermé
cricri2394 Messages postés 150 Date d'inscription samedi 30 septembre 2006 Statut Membre Dernière intervention 13 janvier 2015 - 11 août 2014 à 17:31
cricri2394 Messages postés 150 Date d'inscription samedi 30 septembre 2006 Statut Membre Dernière intervention 13 janvier 2015 - 13 août 2014 à 15:25
Bonjour,

j'ai un soucis sur symfony2 (couplé à git).

sur la branche sur laquelle je travaille, lors d'un appel ajax qui doit renvoyer un formulaire, il y a un bug qui génère le message suivant :

An exception has been thrown during the rendering of a template ("The option "0" does not exist. Known options are: "action", "attr", "auto_initialize", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_provider", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "inherit_data", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "mapped", "max_length", "method", "pattern", "post_max_size_message", "property_path", "read_only", "required", "translation_domain", "trim", "validation_groups", "virtual"")

Même en changeant en dur le paramètres numérique pour voir, cela ne change rien.

Sur la branche master, aucun soucis. J'ai eu l'idée de faire un git diff sur les dossiers des 2 branches pour voir les différences mais je ne vois rien.

Si quelqu'un avait une piste.
Merci.

4 réponses

CptRomaiin Messages postés 315 Date d'inscription mercredi 23 octobre 2013 Statut Membre Dernière intervention 28 avril 2016 58
13 août 2014 à 12:41
Salut,

Peux tu poster le code de la fonction du controller qui génère la réponse ajax ainsi que le code du template du formulaire que le controller est censé renvoyer ?
0
cricri2394 Messages postés 150 Date d'inscription samedi 30 septembre 2006 Statut Membre Dernière intervention 13 janvier 2015 1
13 août 2014 à 14:50
Bonjour, merci pour ta réponse,

Fonction générant la réponse ajax

<?php

public function ajaxProgrammeDetailsAction(Request $request)
{

$currentUser = $this->container->get('security.context')->getToken()->getUser();

if (false === $this->get('security.context')->isGranted('ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES', 'EDIT'))
throw new AccessDeniedException();

$currentUserClientLink = $currentUser->getAdmLienUtilisateurClientCourant();

$programme = $this->getDoctrine()
->getManager()
->getRepository('AssuranceBundle:PoliceProgramme')
->getById($request->request->get('id'), $currentUserClientLink->getSadmClient()->getId(), $currentUserClientLink->getSadmLangue()->getId());

$polices = array();

foreach ($programme->getPolices() as $p) {
$polices[$p->getLimite()] = $p;
}

krsort($polices);

// formulaire 1
if(true === $this->get('security.context')->isGranted('ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES', 'EDIT')){
$form = $this->get('form.factory')->createNamedBuilder('_Form_PoliceProgramme_Edit', '_Form_PoliceProgramme', $programme)->getForm();
}
else{
$form = null;
}
// fin formulaire 1

$tableCoordination = $this->container->get('_core.class_table_coordination');
$tableCoordination->setParams(array('id' => $request->request->get('id')));
$tableCoordination->initialize();

$police = new Police();
$police->setAdmStructure($programme->getAdmStructure());
$police->setPoliceProgramme($programme);
$police->setAdmParamDonneeBranche($programme->getAdmParamDonneeBranche());
$police->setDevId($programme->getDevId());

// formulaire 2
if(true === $this->get('security.context')->isGranted('ROUTE_TRANSFERT_ASSURANCE_POLICES', 'WRITE')){
$policeForm = $this->createForm('_Form_Police', $police);
}
else{
$policeForm = null;
}
// fin formulaire 2


// formulaire 3
$coordination = new PoliceCoordination();
if(true === $this->get('security.context')->isGranted('ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE', 'WRITE')){
$form_c = $this->createForm('_Form_PoliceCoordination', $coordination);
}
else{
$form_c = null;
}
// fin formulaire 3

$structures = $this->getDoctrine()->getManager()
->getRepository('AdminBundle:admStructure')->getStructureByClientAndFilter(
$currentUserClientLink->getSadmClient()->getId(),
$currentUser->getId(), 0);

return $this->render('AssuranceBundle:Programme:ajaxProgrammeDetails.html.twig', array(
'programme' => $programme,
'polices' => $polices,
'form' => $form->createView(),
'form_c' => $form_c->createView(),
'structures' => $structures,
'tableCoordination' => $tableCoordination->getString(array('style' => 'width: 1400px')),
'policeForm' => $policeForm->createView()));

}

Code du twig


<div id="zone-for-resize-search" class="span7 offset5 mb30">
<div id="zone-detail" class="zone">
<div id="infosSite">
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES", "EDIT") %}
<form method="POST" action="{{path("_Assurance_Transfert_Assurance_Update", {"programme": programme.id} )}}" onsubmit="" id="update_structure" class="form-table">
{% endif %}
{% spaceless %}
{# définition du programme #}
<h2 class="zone-header zone-header-white">{{ getMessage(74) }}<span id="entitee_name"></span>
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES", "EDIT") %}
<span class="actions pull-right">
<span class="on-non-edit">
<a href="#" class="icon-edit" data-toggle="edit-mode" data-target="#zone-detail"></a>
</span>
<span class="on-edit">
<a href="#" class="btn btn-rounded" data-dismiss="edit-mode">Annuler</a> 
<input type="submit" value="Valider" class="btn btn-rounded" />
</span>
</span>
{% endif %}
</h2>
{% endspaceless %}
<div id="content_details_structure">
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES", "EDIT") %}
<table class="table table-column table-condensed on-edit">
<tbody>
<tr class="separator">
{# Souscripteur #}
<th class="span3"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(73) }}</th>
<td class="span3">
<span>
{{form_widget(form.admStructure)}}
</span>
</td>
{# Nom du programme #}
<th class="span3"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(189) }}</th>
<td class="span3">
<span>
{{form_widget(form.libelle)}}
</span>
</td>
</tr>
<tr>
{# N° programme #}
<th class="span3"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(198) }}</th>
<td class="span3">
<span>
{{form_widget(form.num)}}
</span>
</td>
{# Branche #}
<th class="span3"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(207) }}</th>
<td class="span3">
<span>
{{form_widget(form.admParamDonneeBranche)}}
</span>
</td>
</tr>
<tr>
{# Date de début #}
<th class="span3"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(71) }}</th>
<td class="span3">
<span>
{{form_widget(form.dateDeb)}}
</span>
</td>
{# Date de fin #}
<th class="span3"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(72) }}</th>
<td class="span3">
<span>
{{form_widget(form.dateFin)}}
</span>
</td>
</tr>
<tr class="separator">
{# Devise du programme #}
<th class="span3" style="vertical-align: middle"><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(199) }}</th>
<td class="span3">
<span>
{{form_widget(form.devId)}}
</span>
</td>
{# Coordination internationale #}
<th class="span3">{{ getMessage(100) }}</th>
<td class="span3">
<span>
{{form_widget(form.coordination)}}
</span>
</td>
</tr>
<tr>
{#Commentaire #}
<th class="span3">{{ getMessage(101) }}</th>
<td colspan="3">
<span>
{{form_widget(form.commentaire)}}
</span>
</td>
</tr>
</tbody>
</table>
{{ form_rest(form) }}
{{ form_javascript(form) }}
{{ form_stylesheet(form) }}
{% endif %}

<table class="table table-column table-condensed on-non-edit">
<tbody>
<tr class="separator">
{# Souscripteur #}
<th class="span3">{{ getMessage(73) }}</th>
<td class="span3">
<span>
{{programme.admStructure}}
</span>
</td>
{# Nom du programme #}
<th class="span3">{{ getMessage(189) }}</th>
<td class="span3">
<span>
{{programme.libelle}}
</span>
</td>
</tr>
<tr>
{# N° programme #}
<th class="span3">{{ getMessage(198) }}</th>
<td class="span3">
<span>
{{programme.num}}
</span>
</td>
{# Branche #}
<th class="span3">{{ getMessage(207) }}</th>
<td class="span3">
<span>
{{programme.admParamDonneeBranche}}
</span>
</td>
</tr>
<tr>
{# Date de début #}
<th class="span3">{{ getMessage(71) }}</th>
<td class="span3">
<span>
{{programme.dateDeb|localizeddate('short', 'none')}}
</span>
</td>
{# Date de fin #}
<th class="span3">{{ getMessage(72) }}</th>
<td class="span3">
<span>
{{programme.dateFin|localizeddate('short', 'none')}}
</span>
</td>
</tr>
<tr class="separator">
{# Devise du programme #}
<th class="span3" style="vertical-align: middle">{{ getMessage(199) }}</th>
<td class="span3">
<span>
{{programme.devId}}
</span>
</td>
{# Coordination internationale #}
<th class="span3">{{ getMessage(100) }}</th>
<td class="span3">
<span>
{% if programme.getCoordination == 1%}Oui {% else %}Non{% endif %}
</span>
</td>
</tr>
<tr>
{#Commentaire #}
<th class="span3">{{ getMessage(101) }}</th>
<td colspan="3">
<span>
{{programme.commentaire}}
</span>
</td>


</tr>
</tbody>
</table>
</div>
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES", "EDIT") %}
</form>
{% endif %}
</div>
<div class="quick-access-zone">
<ul>
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "READ") %}
<li><a href="#montage_container" data-scrollable-zone="content-scrollable-zone">{{ getMessage(102) }}</a></li>
{% endif %}
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "READ") %}
<li><a href="#coordination-container" data-scrollable-zone="content-scrollable-zone">{{ getMessage(100) }}</a></li>
{% endif %}
{% if is_granted("ROUTE_TRANSVERSE_DOCUMENTS", "READ") %}
{# Documents liés #}
<li><a href="#moduledocument" data-scrollable-zone="content-scrollable-zone">{{ getMessage(587) }}</a></li>
{% endif %}
</ul>
</div>
</div>
</div>


<div class="span7 offset5" data-resized-by="zone-search">
<div id="content-scrollable-zone" class="scrollable-zone-outside" data-theme="dark" data-auto-height="true">
{% if (is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "READ") or is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "WRITE")) %}
<div id="montage_container" class="zone collapsable-zone">
<h2 class="zone-header zone-header-inverse" data-toggle="collapse" data-target="#zone-montage">{{ getMessage(102) }}
<span class="actions pull-right">
<a href="#" class="icon--fullscreen fullscreen" data-modal-title="Montage" data-modal-body-id="zone-montage"></a>
</span>
</h2>

<!-- Ligne d'outils -->
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "WRITE") %}
<div id="zone-montage" class="content in">
<div class="zone-actions">
{#Ajouter une police#}
<a class="btn btn-secondary btn-mini btn-rounded" href="#" id="add_montage">+ {{ getMessage(230) }}</a>
</div>
{% endif %}

<!-- /Ligne d'outils -->
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "READ") %}
{% if programme.polices|length %}
<table class="table table-column table-bordered">
<tbody>
<tr>
<th style="text-align: center">{{ getMessage(97) }}</th>
<th style="text-align: center">{{ getMessage(200) }}</th>
<th style="text-align: center">{{ getMessage(201) }}</th>
<th style="text-align: center">{{ getMessage(103) }}</th>
<th style="text-align: center">{{ getMessage(104) }}</th>
<th style="text-align: center">{{ getMessage(105) }}</th>
</tr>

{% for police in programme.polices %}
<tr>
<td class="span2"></td>
<td class="span3">{{police.libelle}}</td>
<td class="span3">{{police.num}}</td>
<td class="span3">{{police.franchise}}</td>
<td class="span3">{{police.admParamDonneeType.getCurrentAdmParamDonneeLibelle.libelle}}</td>
<td class="span3">{{police.limite}}</td>
</tr>
{% endfor %}
</tbody>
</table>

<table class="table table-column table-condensed">
<tbody>
{% for police in polices %}
<tr class="separator">
<td class="span3">{{police.limite}}</td>
<td class="span3">{{police.libelle}}</td>
<td class="span3"></td>
<td class="span3"></td>
<td class="span3"></td>
</tr>
<tr>
<td class="span3">{{police.franchise}}</td>
<td class="span3"></td>
<td class="span3"></td>
<td class="span3"></td>
<td class="span3"></td>
</tr>
{% endfor %}
</tbody>
</table>
{%endif%}
{% endif %}
</div>
</div>
{% endif %}
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "WRITE") %}
<!-- Ajout police -->

<div class="content in mt30" style="display:none" id="zone_new_police">
<h2 class="zone-header zone-header-inverse" data-target="#zone-montage" data-toggle="collapse">{{ getMessage(217) }}
<span class="actions pull-right">
<a href="#" class="icon--fullscreen">
</a>
</span>
</h2>

{{ include('AssuranceBundle:Police:_policeForm.html.twig', { 'form': policeForm, "routing": "programme", "programme_id" : programme.id, "pays" : programme.admStructure.admParamDonneePays })}}

</div>
{% endif %}

{% if programme.getCoordination == 1%}
{% if (is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "READ") or is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "READ")) %}
<div class="zone collapsable-zone mt30" data-resized-by="zone-search">
{# Coordination internationale #}
<h2 class="zone-header zone-header-inverse" data-toggle="collapse" data-target="#zone-coordination">{{ getMessage(100) }}
<span class="actions pull-right">
<a href="#" class="icon--fullscreen fullscreen" data-modal-title="Coordination" data-modal-body-id="zone-coordination"></a>
</span>
</h2>
<div id="zone-coordination" class="content in">
<div id="coordination-container">

{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "WRITE") %}
<!-- Ligne d'outils -->
<div class="zone-actions">
{# ajout d'une coordination #}
<a class="btn btn-secondary btn-mini btn-rounded" href="#" id="add_coor">+ {{ getMessage(202) }}</a>
<a class="btn btn-secondary btn-mini btn-rounded pull-right" href="#">{{ getMessage(53) }}</a>
</div>
<!-- /Ligne d'outils -->
{% endif %}

{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "READ") %}
<div class="table_zone">
{{ tableCoordination|raw }}
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}
{%endif%}


{% if programme.getCoordination == 1%}
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "WRITE") %}
<div class="zone collapsable-zone mt30" id='new_form_coor' style="display:none">
{#nouvelle coordination#}
<h2 class="zone-header zone-header-inverse" data-toggle="collapse" >{{ getMessage(269)|upper }}<span class="actions pull-right"></h2>
<form method="POST" action="{{path("_Assurance_Transfert_Assurance_Create_Coordination")}}">
<!-- Ligne d'outils -->

<div class="zone-actions">
<a id="btn_back_new_coord" href="#" class="btn btn-secondary btn-mini btn-rounded">< {{ getMessage(134)|upper }}</a>
<input type="submit" class="btn btn-secondary btn-mini btn-rounded pull-right" value="{{ getMessage(11)|upper }} >" />
</div>
<!-- /Ligne d'outils -->
<table class="table table-bordered">
<tr>
{# Type de police #}
<td><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(203) }}</td><td>{{form_widget(form_c.admParamDonneeTypePolice)}}</td>
</tr>
<tr>
{# Obligatoire #}
<td>{{ getMessage(94) }}</td><td>{{form_widget(form_c.flOblig)}}</td>
</tr>
<tr>
{# Admis #}
<td>{{ getMessage(204) }}</td><td>{{form_widget(form_c.flAdmited)}}</td>
</tr>
<tr>
{# Entité #}
<td>{{ getMessage(64) }}</td><td>{{form_widget(form_c.admStructure)}}</td>
</tr>
<tr>
{# Pays #}
<td><span class="required labelStar" title="{{ getMessage(744) }}">*</span>{{ getMessage(10) }}</td><td>{{form_widget(form_c.admParamDonneePays)}}</td>
</tr>
<tr>
{# Utilisateur Entité #}
<td>{{ getMessage(205)|title }}</td><td>{{form_widget(form_c.admUtilisateurEntite)}}</td>
</tr>
<tr>
{# Utilisateur Courtier #}
<td>{{ getMessage(206)|title }}</td><td>{{form_widget(form_c.admUtilisateurCourtier)}}</td>
</tr>
</table>

{{ form_rest(form_c) }}
{{ form_javascript(form_c) }}
{{ form_stylesheet(form_c) }}
<input type='hidden' name="id" value="{{programme.id}}"/>

</form>
<div class="clear"></div>
</div>
{% endif %}
{%endif%}
{% if is_granted("ROUTE_TRANSVERSE_DOCUMENTS", "READ") %}
{# ajout de la base documentaire #}

{% render(controller('BasedocBundle:ModuleDocuments:moduleDocumentDivConstructor', {'id_data' : programme.id,
'appel':'policeProgramme',
'doc_detail_path' : 'ROUTE_Transfert_Assurance_Programmes_Document_Details',
'doc_upload_path' : 'ROUTE_Transfert_Assurance_Programmes_Document_UploadFile' })) %}
{% endif %}
</div>
</div>

<script type="text/javascript">
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES", "EDIT") %}
$('#update_structure').submit(function() {
if(!confirm("{{ getMessage(13) }}")){
e.preventDefault();
return;
}
});
{% endif %}

$(document).ready(function() {
{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_PROGRAMMES", "EDIT") %}
$("#btn_update_structure").click(function(e) {
e.preventDefault();
$("#form_police_programme_update").submit();
})
{% endif %}

{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_COORDINATION_INTERNATIONALE", "WRITE") %}
$("#add_coor").click(function(e) {
$("#new_form_coor").show();
e.preventDefault();
});

$("#btn_back_new_coord").click(function(e) {
e.preventDefault();
$("#new_form_coor").hide();

});
{% endif %}

$("#check_coor_all").change(function() {
$(".check_coor").prop("checked", $("#check_coor_all").prop("checked"));
});

{% if is_granted("ROUTE_TRANSFERT_ASSURANCE_POLICES", "WRITE") %}
$("#add_montage").click(function(e) {
e.preventDefault();
$("#zone_new_police").show();
});

$("#btn_policeForm_bck").click(function(e) {
e.preventDefault();
$("#zone_new_police").hide();
});
{% endif %}

$(".tooltiped").tooltip();

$("#paddle-search").find("span.up").bind("click", function() {
togglePaddleSearch();
});
$(".paddle .collapse, .paddle .expand").bind("click", function() {
togglePaddle(($(this).parent().parent()));
});

getHTMLTable("tableCoordination").init($("#tableCoordination"));

setTimeout(function() {
getHTMLTable("tableCoordination").init("#tableCoordination");
}, 50);

$('.voletOuvrable h2').click(function() {

if ($(this).parent().hasClass('actif'))
{
$(this).parent().removeClass('actif');
}
else
{
$(this).parent().addClass('actif');
}
});

});

$(window).resize(function() {
getHTMLTable("tableCoordination").resizeTable();
});
</script>
0
CptRomaiin Messages postés 315 Date d'inscription mercredi 23 octobre 2013 Statut Membre Dernière intervention 28 avril 2016 58
Modifié par CptRomaiin le 13/08/2014 à 15:08
Alors je suis pas sur de moi mais il y a un truc qui me parait bizarre dans ton contoller :

        $structures = $this->getDoctrine()->getManager()
            ->getRepository('AdminBundle:admStructure')->getStructureByClientAndFilter(
                $currentUserClientLink->getSadmClient()->getId(),
                $currentUser->getId(), 0);

A quoi correspond le 0 à la fin ?
0
cricri2394 Messages postés 150 Date d'inscription samedi 30 septembre 2006 Statut Membre Dernière intervention 13 janvier 2015 1
13 août 2014 à 15:25
Il s'agit d'un paramètre dont la valeur modifie la requête exécutée dans le repository.
0