I want to set value of a text input the value of a column from the database :
<input name="clt_cin_pass" id="clt_cin_pass" type="text" maxlength="25" placeholder="CIN/Passeport" value="{{data.clt_cin_pass}}"/>
The data
variable is gotten from a controller
:
<?php
use Phalcon\Mvc\Controller;
class ReferentielClientController extends Controller
{
...
public function modifierClientAction($id){
$this->view->titre = 'Modification de client';
$critere = array();
$critere["clt_id"] = $id;
$enreg = Client::listerClient($critere);
$this->view->data = $enreg;
return $this->view->pick("client/client");
}
...
}
?>
The model Client is :
<?php
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Query;
class Client extends Model {
function listerClient($critere) {
// Instantiate the Query
$sSQL = "
SELECT c.clt_id as clt_id,c.clt_cin_pass as clt_cin_pass,CONCAT_WS(' ',c.clt_nom,c.clt_prenom) AS noms,c.clt_tel as clt_tel,
c.clt_adresse as clt_adresse,c.clt_comment as clt_comment
FROM client as c WHERE 1 = 1 ";
if(isset($critere["clt_id"]) && $critere["clt_id"] != "") {
$sSQL .= "AND c.clt_id = ' " . $critere["clt_id"] . "' ";
}
$query = new Query($sSQL,$this->getDI());
// Execute the query returning a result if any
$ret = $query->execute();
return $ret;
}
}
?>
The query returns a row , but at runtime the field has no value ! So how to populate the field's value ?