\n";
$aff_option="
";
if($what_sel)$bouton_parcourir="
";
else $bouton_parcourir="";
$aff= str_replace('!!bouton_parcourir!!', $bouton_parcourir, $aff);
$template=$script_js."
";
$template.="
";
$num=0;
if(!isset($values[0]) || !$values[0]) {
$values[0]["label"] = "";
$values[0]["id"]= 0;
$values[0]["objets"] = array();
}
$last_id = end($values)['id'];
foreach($values as $value) {
$label_element=$value["label"];
$id_element=$value["id"];
$temp= str_replace('!!id_element!!', $id_element, $aff);
$temp= str_replace('!!label_element!!', htmlentities($label_element,ENT_QUOTES,$charset), $temp);
$temp= str_replace('!!num!!', $num, $temp);
if($id_element == $last_id){
$temp= str_replace('!!bouton_ajouter!!', "
", $temp);
$temp= str_replace('!!tu_callback!!', 'callback="tu_add_callback"', $temp);
}else{
$temp= str_replace('!!bouton_ajouter!!', "", $temp);
$temp= str_replace('!!tu_callback!!', '', $temp);
}
$template.=$temp;
// option
if(is_array($value["objets"]))
foreach($value["objets"] as $objet) {
$option = str_replace('!!label!!', $objet["label"], $aff_option);
$option = str_replace('!!name!!', $objet["name"], $option);
$option = str_replace('!!class!!', $objet["class"], $option);
$option = str_replace('!!num!!', $num, $option);
$option = str_replace('!!value!!', htmlentities($objet["value"],ENT_QUOTES,$charset), $option);
$template.=$option;
}
$template.="
";
if(!$num) {
$script_option_js = '';
$j=0;
if(is_array($value["objets"]))
foreach($value["objets"] as $objet) {
// Ajout des javascript qui permet la répétabilité des champs option
$option_js = str_replace('!!label!!', addslashes($objet["label"]), $script_js_option);
$option_js = str_replace('!!name!!', $objet["name"], $option_js);
$option_js = str_replace('!!class!!', $objet["class"], $option_js);
$option_js = str_replace('!!num!!', $j, $option_js);
$option_js = str_replace('!!value!!', $objet["value"], $option_js);
$script_option_js.=$option_js;
$j++;
}
$template=str_replace('!!add_option!!',$script_option_js, $template);
}
$num++;
}
$template.="
";
$template.="