00001 <?php
00014 class CampoListaDesplegable extends Campo{
00015 protected $atributos = array('id','clase','lista','editable','tabindex','nulo');
00016
00027 public function __construct($nodo){
00028 parent::__construct($nodo);
00029 if (!isset($this->id)) throw new ExcepcionCampoAtributoObligatorioNoDefinido('id',get_class($this));
00030 }
00034 public function verNodo(){
00035 $xml = new DOMDocument();
00036
00037 $select = $xml->createElement("select");
00038 $select->setAttribute("id", $this->id);
00039 if (isset($this->tabindex))
00040 $select->setAttribute("tabindex", $this->tabindex);
00041 if (isset($this->editable))
00042 if ($this->editable == 'no')
00043 $select->setAttribute("disabled", "disabled");
00044 if (isset($this->nulo))
00045 if ($this->nulo == 'sí'){
00046 $option = $xml->createElement('option');
00047 $option->setAttribute('value', null);
00048 $nombre = $xml->createTextNode('Sin definir');
00049 $option->appendChild($nombre);
00050 $select->appendChild($option);
00051 }
00052
00053
00054 if (isset($this->lista)){
00055 $lista = new ListaAuxiliar($this->lista);
00056 $datos = $lista->ver();
00057 for($i=0; $i<sizeof($datos); $i++){
00058 $option = $xml->createElement("option");
00059 $option->setAttribute("value", $datos[$i]['id']);
00060 $nombre = $xml->createTextNode($datos[$i]['nombre']);
00061 $option->appendChild($nombre);
00062 $select->appendChild($option);
00063 }
00064 }
00065
00066 return $select;
00067 }
00068 }
00069
00071
00072 return true;
00073 ?>