Show the first element of a select value received by post
In my controller
public function editAction($CONT_CODIGO) {
if (!$this->request->isPost()) {
$spm_contacto = SpmContacto::findFirstByCONT_CODIGO($CONT_CODIGO);
if (!$spm_contacto) {
$this->flash->error("spm_contacto was not found");
return $this->dispatcher->forward(array(
"controller" => "spm_contacto",
"action" => "index"
));
}
$this->view->CONT_CODIGO = $spm_contacto->CONT_CODIGO;
$this->tag->setDefault("CONT_CODIGO", $spm_contacto->CONT_CODIGO);
$this->tag->setDefault("CONT_CEDULA", $spm_contacto->CONT_CEDULA);
$this->tag->setDefault("CONT_RUCIDE", $spm_contacto->CONT_RUCIDE);
$this->tag->setDefault("CONT_NOMBRE", $spm_contacto->CONT_NOMBRE);
$this->tag->setDefault("CON_ESTADO", $spm_contacto->CON_ESTADO);
$this->tag->setDefault("CONT_TELEFO", $spm_contacto->CONT_TELEFO);
$this->tag->setDefault("CONT_DIRECC", $spm_contacto->CONT_DIRECC);
$this->tag->setDefault("CONT_AREA", $spm_contacto->CONT_AREA);
$this->tag->setDefault("CONT_CARGO", $spm_contacto->CONT_CARGO);
$this->tag->setDefault("CONT_TIPOXX", $spm_contacto->CONT_TIPOXX);
$this->tag->setDefault("CONT_EMAIL", $spm_contacto->CONT_EMAIL);
$this->tag->setDefault("CONT_USUARIO", $spm_contacto->CONT_USUARIO);
$this->tag->setDefault("CONT_CLAVE", $spm_contacto->CONT_CLAVE);
$this->tag->setDefault("CONT_CLAVEE", $spm_contacto->CONT_CLAVEE);
}
}
in my view
<?php echo $this->tag->textField(array("CONT_AREA", "size" => 30, "class" => "form-control", "id" => "fieldContArea")) ?>
And the item I received by post will replace the text field for select shows as well
<?php
echo Phalcon\Tag::select(array(
"CONT_CARGO", SpmReferencia::find("REFE_CODIGO='00'"),
"using" => array("REFE_CODIGO", "REFE_DESCRI")
,'useEmpty' => true,
'id' => 'fieldContCargo',
'emptyText' => 'Escoge uno...',
'emptyValue' => ''
));
?>
and that the first element is the value received by post