I am creating an application on zend2 and I would like to get help. /* getMessages() returns array('info'=>'INFO','alert'=> 'ALERT','more','MORE'); */ $msg = array(); // my array foreach ($this->getMessages() as $key => $value) {
//print_r($key);die();
if(in_array($key,$user_values))
$msg[$key][1] = 'user';
if(in_array($key,$admin_values))
$msg[$key][2] = 'admin';
if(!in_array($key,$user_values) && !in_array($key,$admin_values))
$msg[$key][] = 'skip';
$form->get(trim($key))->setValueOptions(array($msg));
// OR
$form->get(trim($key))->setValue(array($msg));
// Clear the array
$msg = array();
}
/* Wanna into form :
<input type="checkbox" name="alert[]" value="skip' />
<input type="checkbox" name="alert[]" value="user' />
<input type="checkbox" name="alert[]" value="admin' />
*/
Aucun commentaire:
Enregistrer un commentaire