hi i’m using zend form multicheckbox.
I have an $array in which I have a list of ‘id’ ‘name’ ‘surname’ ‘address’ and ‘city’of a users.
I need to create a checkbox in which i can choose beetwen the name+surname+add+city and return to controler the id of the name and surname selected…
Here is my form:
class Application_Form_MultiplaSelezione extends Zend_Form
{
public function init()
{
/* Form Elements & Other Definitions Here ... */
}
public function selezione($array){
$this->setMethod('post');
$count=count($array);
$multipla=new Zend_Form_Element_MultiCheckbox('scelta');
for($i=0;i<$count;$i++){
foreach ($array[$i] as $chiave=>$valore){
if($chiave=='idnomeutente'){
$nomeutente=$valore;
}
if($chiave=='nome'){
$nome=$valore;
}
if($chiave=='cognome'){
$cognome=$valore;
}
if($chiave=='indirizzo'){
$indirizzo=$valore;
}
if($chiave=='residenza'){
$residenza=$valore;
}
}
$val=$nome.' '.$cognome.' '.$indirizzo.' '.$residenza;
$multipla->addMultiOption($nomeutente, $val);
if($i==0){
$iduser=$nomeutente;
}
}
$multipla->setValue($iduser);
$submit= new Zend_Form_Element_Submit('submit');
$submit->setLabel('Seleziona');
$this->addElements(array($multipla,$submit));
}
}
why doesn’t it work???
Try read and understand this:
To this code you must add some changes in your model and controller. Good Luck 🙂