[eluser]Bionicjoe[/eluser]
This is a hack & slash copy/paste form I'm trying to use.
In option 1 all the fields are pre-populated with data from the record to be edited. That's good, but I have no way to format the form the way I need. Not every field can be a simple input field.
I need a form that looks like option 2, but I'm having trouble getting the fields to populate with data from the record.
Option 1
Code:
<?php
echo form_open('update');
echo form_hidden('outageid', $row[0]->outageid);
// an array of the fields in the outage table
$field_array = array('ticketnumber', 'servicename', 'summary', 'sitename', 'starttime', 'endtime');
foreach($field_array as $field_name)
{
echo '<p>' . $field_name;
echo form_input($field_name, $row[0]->$field_name) . '</p>' . "\r";
}
// not setting the value attribute omits the submit from the $_POST array
echo form_submit('', 'Update');
Option 2
Code:
$this->load->helper('array');
echo form_open('update');
echo form_hidden('outageid', $row[0]->outageid);
// an array of the fields in the outage table
$field_array = array('ticketnumber', 'servicename', 'summary', 'sitename', 'starttime', 'endtime');
<table>
<tr><td>Number</td><td><input type="text" name="ticketnumber" value="<?php echo element('ticketnumber', $field_array)?>"></td><tr>
<tr><td>Affected Services</td><td><?php echo form_dropdown('servicename', $serviceoptions); ?></td><tr>
<tr><td>Summary</td><td><input type="text" name="summary"></td><tr>
<tr><td>Location</td><td><?php echo form_multiselect('sitename', $siteoptions); ?></td><tr>
<tr><td>Start</td><td><input type="text" name="starttime"></td><tr>
<tr><td>End</td><td><input type="text" name="endtime"></td><tr>
<tr><td></td><td><input type="submit" value="Submit"></td><tr>
</table>
*/
echo form_close();