/** @param array $objects of $type to derive the options from
* @param string $type of the objects, must have a ClassDescriptor that supports ::getPeanutWithId
*/
function ($objects, $type) {
$options = array();
$cnv = $this->();
$this->optionsMaxLength = 0;
$selectedIdInOptions = false;
$clsDes = PntClassDescriptor::getInstance($type);
$idProp = $clsDes->('id');
$cnv->($idProp);
forEach($objects as $obj)
if ($this->($options, $obj, $type, $cnv, $idProp))
$selectedIdInOptions = true;
if ($this->() && !$selectedIdInOptions) {
$selectedItem = $clsDes->($this->());
if ($selectedItem)
$this->($options, $selectedItem, $type, $cnv, $idProp);
}
$this->($options);
}
|