1
Dear All,
I am having the following problem when trying to edit a poll:
The edit form is coming up fine, but in the poll options I just get the name of the last option repeated (so, if my options are foo,bar and foobar I will get foobar three times).
I had a look at the code under xoopspoll//class/index.php and it seems that the code handling that is the following:
$options_arr =& XoopsPollOption::getAllByPollId($poll->getVar("poll_id"));
$notify_value = 1;
if ( $poll->getVar("mail_status") != 0 ) {
$notify_value = 0;
}
$notify_yn = new XoopsFormRadioYN(_AM_NOTIFY, "notify", $notify_value);
$poll_form->addElement($notify_yn);
$option_tray = new XoopsFormElementTray(_AM_POLLOPTIONS, "");
$barcolor_array =& XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH."/modules/xoopspoll/images/colorbars/");
$i = 0;
foreach($options_arr as $option){
$option_text = new XoopsFormText("", "option_text[]", 50, 255, $option->getVar("option_text"));
$option_tray->addElement($option_text);
$option_id_hidden = new XoopsFormHidden("option_id[]", $option->getVar("option_id"));
$option_tray->addElement($option_id_hidden);
My undertanding of that code is that it should be adding a textbox with the name of the option every time it loops through the options array. However, it only remembers the name of the last option and I could not figure out why, even after looking at class/xoopsform/elementtray.php.
Can somebody please point out what the problem is?
Thanks,
George