Trouble with Select Box Array
Posted on 2007-07-29
Good Morning Experts,
I have a Joomla installation that I have added a component to called "Easy Calendar" I have added some fields to the database that we need to capture and in turn have added those fields to the php page that it draws from. The fields that I need to add are drop down boxes and the elements of them pull from an array.
The issue becomes this, when I add a new record everything works. The field drops down and allows a selection and upon save the record gets populated back to the database.
But when I go back to the record to edit it, the drop down box is set back to the default "Please Select" and not the value from the database. So when it gets saved again the entry for that field gets wiped out.
First there are two pages. The events.php and which houses all the arrays and then the actual admin.easycalendar.html.php page that houses the form.
Here is the array from the events.php page:
$dinnerArray = array();
$dinnerArray->text = "Please Select";
$dinnerArray->value = "0";
$dinnerArray->text = "Y";
$dinnerArray->value = "1";
$dinnerArray->text = "N";
$dinnerArray->value = "2";
$dinnerArray->text = "BFST";
$dinnerArray->value = "3";
$dinnerArray->text = "LUNCH";
$dinnerArray->value = "4";
$dinnerArray->text = "REF";
$dinnerArray->value = "5";
$lists['dinner'] = mosHTML::selectList($dinnerArray, 'dinner', 'class="text_area"', 'value', 'text', $row->dinner);
Here is the information from the admin.easycalendar.html.php page
<?php echo $lists['dinner'] ?>
I know it has something to do with the array, because if I just put a text box in place of the drop down, it works fine. The only thing is I have to manually enter the data into the field.
Any help anyone could provide, would be greatly appreciated.