moodleform and foreach loop

Re: moodleform and foreach loop

by Alexander Dominicus -
Number of replies: 0
Picture of Testers
EDIT:
I partially solved the problem like this:

reset( $this->_customdata['answers']);

for($i = 1; $i <= 4;$i++) {
$mform->addElement('hidden',"hidden_".$i, current($this->_customdata['answers'])->id );
$mform->setType('hidden_'.$i , PARAM_INT);
next( $this->_customdata['answers']);
}
which is really dirty and give the notices
"Trying to get property 'id' of non-object in...."
Moreover, the number of answers is hard coded, which is also really bad....