I'm extending the employee page in admin prestashop to add an input text zip code and city checkboxs which i would to be created dynamically after entring the zip cod, i used a function to retrieve cities and create checkboxsbut it doesn't work
public function ajaxProcessGetVille(){
$zip_cod = Tools::getValue('zip_cod');
$html = file_get_contents("http://ift.tt/1BFEAgx".$zip_cod);
$i = 0;
$s = strlen($html);
$htmlF = "";
for( $i = 0; $i < ($s - 188) ; $i++){
$htmlF = $htmlF.$html[$i + 186];
}
$c = $json = json_decode($htmlF)->count;
$f = "";
$options = array();
for( $i = 1; $i <= $c ; $i++){
$f = "".$i."";
$ville = json_decode($htmlF)->$f->ville;
$options[] = array(
"id" => $ville,
"name" => $ville
);
}
//var_dump($this->fields_form);exit();
//$this->fields_form =$this->fileds_temp;
$this->fields_form['input'][]= array(
'type' => 'checkbox', // This is an <input type="checkbox"> tag.
'label' => $this->l('Options'), // The <label> for this <input> tag.
'desc' => $this->l('Choose options.'), // A help text, displayed right next to the <input> tag.
'name' => 'options', // The content of the 'id' attribute of the <input> tag.
'values' => array(
'query' => $options, // $options contains the data itself.
'id' => 'id_option', // The value of the 'id' key must be the same as the key for 'value' attribute of the <option> tag in each $options sub-array.
'name' => 'name' // The value of the 'name' key must be the same as the key for the text content of the <option> tag in each $options sub-array.
));
return parent::renderForm();
//die($htmlF);
}
When i tested the form variable $this->fields_form it retrun null, before adding the checkbox adding code with $this->fields_form['input'][], any one have any idea and thanks.
Aucun commentaire:
Enregistrer un commentaire