ajout des champs multiples

This commit is contained in:
Damien LASSERRE 2012-04-05 09:04:34 +00:00
parent b3bc52e460
commit e2bc5393a7

View File

@ -137,13 +137,17 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract
private function selectMultipleHTML($name, $field) private function selectMultipleHTML($name, $field)
{ {
$session = new SessionCiblage(); $session = new SessionCiblage();
$return = '<select class="criteres" name="'.$name.'">';
$return .= '<option value="tous">Tous</option>'; $sessionValeur = $session->getCritere($name);
if(is_array($sessionValeur))
$sessionValeur = implode(',', $sessionValeur);
$return = '<select size="'.count($field['fields'][$field['type']]['value']).'" class="criteres '.$field['type']['class'].'" name="'.$name.'" multiple>';
$return .= '<option '.(($sessionValeur == 'tous')?'selected':'').' value="tous">Tous</option>';
foreach($field['fields'][$field['type']]['value'] as $value => $label) { foreach($field['fields'][$field['type']]['value'] as $value => $label) {
$selected = ""; $selected = "";
if(($session->getCritere($name) != null) and $session->getCritere($name) == $value) if(($sessionValeur != null) and $sessionValeur == $value and $sessionValeur != "tous")
$selected = " selected"; $selected = " selected";
$return .= '<option'.((!empty($selected))?$selected:null).' value="'.$value.'">'.$label.'</option>'; $return .= '<option'.$selected.' value="'.$value.'">'.$label.'</option>';
} }
$return .= '</select>'; $return .= '</select>';
return ($return); return ($return);