IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

[Symfony2] : afficher valeur sélectionné dans liste déroulante


Sujet :

Symfony PHP

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    97
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 97
    Points : 47
    Points
    47
    Par défaut [Symfony2] : afficher valeur sélectionné dans liste déroulante
    Bonjour,

    J'ai crée une liste déroulante dans mon formulaire. Les valeurs de cette liste proviennent d'une autre table que celle du formulaire. Voici la liste déroulante.




    Tout se passe pour le mieux sauf que maintenant, j'aimerais récupérer la valeur sélectionnée dans a liste déroulante (ici Event) afin de faire des tests plus bas. Car j'aimerais dire que si la valeur est Event alors, je fais l'action 1, si c'est autre chose, action 2 etc.

    Petit hic, j'ai cette erreur :

    An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class Proxies\AdlHiringBundleEntityFcontacttypeProxy could not be converted to string in E:\Web\WampSites\Symfony\app\cache\dev\twig\f0\78\ade14feebe63cfddfd593535dd02.php line 345") in "AdlHiringBundle:Candidate:edit.html.twig" at line 124.

  2. #2
    Membre éclairé

    Profil pro
    Inscrit en
    Juin 2004
    Messages
    772
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Juin 2004
    Messages : 772
    Points : 872
    Points
    872
    Par défaut
    Montre nous le code de ce fichier : AdlHiringBundle:Candidate:edit.html.twig

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    97
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 97
    Points : 47
    Points
    47
    Par défaut
    Pour infos, property a la valeur FIRSTCONTACTTYPE dans mon CandidateType.

    Je n'ai donc pas de méthode __toString(). Dois-je en utiliser une ? Si oui comment l'implémenter ?


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    {% extends "AdlHiringBundle::layout.html.twig" %}
     
    {% block title %} 	{{ parent() }} - Edit Candidate {entity.id}	{% endblock %}
     
     
    {% block menu_left %}
    	{% block menu_candidates %}	 {{ parent() }}		{% endblock %}	
    {% endblock %}	
     
    {% block body %}
     
    			{% block title1  %}<h1>Edit Candidate {{entity.id}}	</h1>{% endblock %}
     
     
     
     
    		<form action="{{ path('candidate_update', { 'id': entity.id }) }}" method="post" {{ form_enctype(edit_form) }}>
    		{{ form_errors(edit_form) }}
    		<div class="buttons">
    					<button type="submit" name="delete">Update candidate</button>
    					<a href="{{path('candidate_delete',{'id':entity.id})}}">Delete candidate</a>
    		</div>	
     
    		<table class="table_01">
    		<thead>
    			<tr>
    				<th class="normal">Field</th>
    				<th class="normal">Value</th>
    				<th class="actions" colspan="2">
    					<div class="buttons">
    								<a href="{{ path('candidate') }}">Back to the list</a>
    					</div>
    				</th>
    			</tr>
     
    		</thead>
     
    		<tfoot>
     
    		</tfoot>
     
    		<tbody>
     
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.PREFIX,'Prefix :', { 'attr': {'class': 'inputspecial_label'} }) }}</td>
    					  <td colspan="4">{{ form_widget(edit_form.PREFIX,{ 'attr': {'class': 'inputspecial_input'} }) }}{{ form_errors(edit_form.PREFIX) }}</td>
    				</tr>
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.LASTNAME,'Lastname :', { 'attr': {'class': 'inputspecial_label'} }) }}</td>
    					  <td colspan="4">{{ form_widget(edit_form.LASTNAME,{ 'attr': {'class': 'inputspecial_input'} }) }}{{ form_errors(edit_form.LASTNAME) }}</td>
    				</tr>
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.FIRSTNAME,'Firstname :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.FIRSTNAME,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.FIRSTNAME) }}</td>
    				</tr>
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.NATIONALITY,'Nationality :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.NATIONALITY,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.NATIONALITY) }}</td>
    				</tr>
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.BIRTHDATE,'Birthdate :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.BIRTHDATE,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.BIRTHDATE) }}</td>
    				</tr>				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.STREET,'Street :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.STREET,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.STREET) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.CITY,'City :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.CITY,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.CITY) }}</td>
    				</tr>					
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.ZIPCODE,'Zip code :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.ZIPCODE,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.ZIPCODE) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.PROVINCESTATE,'Province/state :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.PROVINCESTATE,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.PROVINCESTATE) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.EMAIL,'Email :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.EMAIL,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.EMAIL) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.PHONE,'Phone :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.PHONE,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.PHONE) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.CELLPHONE,'Cell phone :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.CELLPHONE,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.CELLPHONE) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.fcontacttype,'First contact type :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.fcontacttype,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.fcontacttype) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.FIRSTCONTACTDATE,'First contact date :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.FIRSTCONTACTDATE,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.FIRSTCONTACTDATE) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.POSITIONCONSIDERED,'Position considered :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.POSITIONCONSIDERED,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.POSITIONCONSIDERED) }}</td>
    				</tr>				
    				<tr>
    					  <td class="inputspecial_firstcolumn">{{ form_label(edit_form.STATUS,'Status :', { 'attr': {'class': 'inputspecial_label'} }) }} </td>
    					  <td colspan="4">{{ form_widget(edit_form.STATUS,{ 'attr': {'class': 'inputspecial_input'} }) }} {{ form_errors(edit_form.STATUS) }}</td>
    				</tr>	
     
    	{{ form_rest(edit_form) }}
     
    			</tbody>
    		</table>	
     
    		<div class="buttons">
    					<button type="submit" name="delete">Update candidate</button>
    					<a href="{{path('candidate_delete',{'id':entity.id})}}">Delete candidate</a>
    		</div>		
     
     
    		</form>
    			{% set firstcontacttype =''%}	
    		<div class="subform">
    				<form action="" method="post" {{ form_enctype(sub_form) }}>
     
    				{{entity.fcontacttype}}
     
     
    						{% if firstcontacttype =='Event' %}
     
    							<fieldset class="fieldset_00">
    							    <legend class="legend_00">Choose an action</legend>
     
    								<div class="radio"><label class="label_radio">Process 1 + scoring </label><input class="" type="radio" name="action" value="process1"/></div>
    								<div class="radio"><label class="label_radio">Reject</label><input type="radio" name="action" value="reject"/></div>
     
    							</fieldset>
     
    						{% endif %}
     
    						{% if firstcontacttype =='Free application' %}
    							<fieldset class="fieldset_00">
    							    <legend class="legend_00">Choose an action</legend>
     
    								<div class="radio"><label class="label_radio">Process 1</label><input class="" type="radio" name="action" value="process1"/></div>
    								<div class="radio"><label class="label_radio">Process 2</label><input type="radio" name="action" value="process2"/></div>
    								<div class="radio"><label class="label_radio">Reject</label><input type="radio" name="action" value="reject"/></div>
     
    							</fieldset>
    						{% endif %}
     
    						{% if firstcontacttype =='Headhunter' %}
     
    							<fieldset class="fieldset_00">
    							    <legend class="legend_00">Choose an action</legend>
     
    								<div class="radio"><label class="label_radio">Process 2</label><input class="" type="radio" name="action" value="process1" checked="checked"/></div>
     
    							</fieldset>
     
    						{% endif %}
    				</form>
    		</div>
     
     
     
    En fonction du statut du candidat, on aura ici un bouton  permettant d'enregistrer un rendez-vous 
    {% endblock %}

  4. #4
    Membre averti
    Homme Profil pro
    Développeur Web
    Inscrit en
    Avril 2004
    Messages
    318
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2004
    Messages : 318
    Points : 362
    Points
    362
    Par défaut
    La méthode __toString() se place directement dans l'entité. Mais j'avoue que j'aimerais bien aussi la placer ailleurs, de ne pas toucher à ce qui a été généré (oui c'est utopique je sais !).

Discussions similaires

  1. [AC-2010] Valeur sélectionnée dans liste déroulante = lecture dans la table
    Par Manolita dans le forum Access
    Réponses: 1
    Dernier message: 04/06/2015, 20h33
  2. Réponses: 3
    Dernier message: 12/11/2010, 23h14
  3. Réponses: 4
    Dernier message: 19/10/2008, 10h25
  4. [VBA]Valeur suivante dans Liste déroulante
    Par Simon2 dans le forum VBA Access
    Réponses: 8
    Dernier message: 17/04/2007, 03h18
  5. afficher deux colonnes dans listes déroulantes
    Par maxeur dans le forum Access
    Réponses: 8
    Dernier message: 26/01/2007, 09h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo