Je reviens désormais avec une nouvelle question, je désire mettre en place une liste déroulante dans mon formulaire. J'ai regardé dans le helper html et l'on trouve le $this->selectTag, le helper m'indique ceci :
Quote:
/**
* Returns a formatted SELECT element.
*
* @param string $fieldName Name attribute of the SELECT
* @param array $optionElements Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element
* @param mixed $selected Selected option
* @param array $selectAttr Array of HTML options for the opening SELECT element
* @param array $optionAttr Array of HTML options for the enclosed OPTION elements
* @param boolean $show_empty If true, the empty select option is shown
* @param boolean $return Whether this method should return a value
* @return string Formatted SELECT element
* @access public
*/
function selectTag($fieldName, $optionElements, $selected = null, $selectAttr = array(), $optionAttr = null, $showEmpty = true, $return = false) {
$this->setFormTag($fieldName);
if ($this->tagIsInvalid($this->model, $this->field)) {
if (isset($selectAttr['class']) && trim($selectAttr['class']) != "") {
$selectAttr['class'] .= ' form_error';
} else {
$selectAttr['class'] = 'form_error';
}
}
if (!isset($selectAttr['id'])) {
$selectAttr['id'] = $this->model . Inflector::camelize($this->field);
}
if (!is_array($optionElements)) {
return null;
}
if (!isset($selected)) {
$selected = $this->tagValue($fieldName);
}
if (isset($selectAttr) && array_key_exists("multiple", $selectAttr)) {
$select[] = sprintf($this->tags['selectmultiplestart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr));
} else {
$select[] = sprintf($this->tags['selectstart'], $this->model, $this->field, $this->parseHtmlOptions($selectAttr));
}
if ($showEmpty == true) {
$select[] = sprintf($this->tags['selectempty'], $this->parseHtmlOptions($optionAttr));
}
foreach($optionElements as $name => $title) {
$optionsHere = $optionAttr;
if (($selected != null) && ($selected == $name)) {
$optionsHere['selected'] = 'selected';
} else if(is_array($selected) && in_array($name, $selected)) {
$optionsHere['selected'] = 'selected';
}
$select[] = sprintf($this->tags['selectoption'], $name, $this->parseHtmlOptions($optionsHere), h($title));
}
$select[] = sprintf($this->tags['selectend']);
return $this->output(implode("\n", $select), $return);
}
A quoi correspondent exactement les variables $fieldName, $optionElements, $selectAttr, $optionAttr, $show_empty et $return.
Car pour l'instant j'arrive à afficher du texte dans ma liste de sélection, mais je n'arrive pas à définir les autres variables, je n'arrive pas à comprendre exactement leur utilité meme si je sais qu'elles en ont une importante.
En plus je dois croiser 2 tables de ma base de données ensemble et je ne sais pas encore comment je vais m'y prendre, ça viendra après