This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.0 » sf_params and select_tag multiple
sf_params and select_tag multiple [message #100221] Wed, 02 June 2010 10:10 Go to next message
anakrys  is currently offline anakrys
Messages: 9
Registered: February 2010
Junior Member

I have a some problems with selects_tags multiples

I try 2 ways to create it :
<?php echo select_tag('id_formation_requise', options_for_select($OffListeTypeFormationRequises,
$sf_request->getParameter('id_formation_requise', $OffOffre->getIdTypeFormationsRequises())
), array('multiple' => 'true',
'size' => 7,
)) ?>

With the function
static public function getTableauForSelectTag($c = null){
		if (!$c)
		$c = new Criteria();

		$_TableauForSelectTag = array();
		$OffListeTypeFormationRequises = OffListeTypeFormationRequisePeer :: doSelect($c);
		foreach($OffListeTypeFormationRequises as $OffListeTypeFormationRequise)
			$_TableauForSelectTag[$OffListeTypeFormationRequise->getIdTypeFormationRequise()] = $OffListeTypeFormationRequise->getLibelle();

		return $_TableauForSelectTag;

<?php echo select_tag('id_sous_secteur_activite', objects_for_select($OffListeTypeFormationRequise,
$sf_params->get('id_formation_requise') ?
$sf_params->get('id_formation_requise') :
), array('multiple' => 'true',
'size' => 7)) ?>

So, it create a multiselect tag.
When I open come on the form for the 1rst time, I give it an array (with $OffOffre->getIdTypeFormationRequises()) which look like :
array(2) { [0]=> int(1) [1]=> int(2) }
So, it select the both values
<select name="id_formation_requise[]" id="id_formation_requise" multiple="multiple" size="7"><option value="1" selected="selected">Ecole d'ingénieur</option>
<option value="2" selected="selected">Ecole de commerce</option>


But, when i do an error in the form, the repopulating does stranges things
When i print the sf_params it looks like :
array(2) { [0]=> int(1) [1]=> int(2) } (same as inital datas)
But, the select_tag select only the first value (even if it wasn't selected before)

The HTML code looks like :
<select name="id_formation_requise[]" id="id_formation_requise" multiple size="7"><option value="1" selected>Ecole d'ingénieur</option>

<option value="2">Ecole de commerce</option>

You can see that multiple and selected params have no values

It's the same with both options_for_select and objects_for_select

Have you an idea?

EDIT: When I delete the fillin part of the validate yml, it works, but not input_tags

[Updated on: Wed, 02 June 2010 10:13]

Re: sf_params and select_tag multiple [message #100223 is a reply to message #100221 ] Wed, 02 June 2010 10:37 Go to previous message
anakrys  is currently offline anakrys
Messages: 9
Registered: February 2010
Junior Member
The trick give by
doesn't work (I saw it after posting this post)
Previous Topic:Form didn't return errors
Next Topic:symfony command issue
Goto Forum:

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software