/** set options using the labels of the values as keys and as HTML as values
* @param array $values of mixed
* @param string $type of value
* @param PntStringConverter $cnv initialized to convert the $values toLabel and toHtml
*/
function ($values, $type, $cnv) {
$options = array();
$this->optionsMaxLength = 0;
$selectedIdInOptions = false;
forEach($values as $value) {
$label = $cnv->($value, $type);
$html = $cnv->($label);
$options[$label] = $html;
$this->optionsMaxLength = max($this->optionsMaxLength, strLen($label));
if ($label == $this->()) $selectedIdInOptions = true;
}
if (strLen($this->()) && !$selectedIdInOptions) {
$options[$this->()] = $cnv->($this->());
}
$this->($options);
}
|