[eluser]scottelundgren[/eluser]
Is there an elegant way for a view to be used for both data entry of a new record and editing an existing record? I'm trying to add the following logic. If you see a good way to combine these samples of 2 views into 1 view and retain validation I'd appreciate it. Thanks!
look up student record
if a record is found, load the data from the row into $data, pass $data into the view:
Code:
<tr>
<td width="85%">I take attendance </td>
<td width="15%" align="center" valign="middle"><?=form_dropdown('attendance',$options, $attendance)?></td>
</tr>
<tr>
<td>Number of Absences </td>
<td align="center" valign="middle"><input name="absences" type="text" size="3" maxlength="3" value="<?=$absences?>"/></td>
</tr>
if a record is not found, just load the view:
Code:
<tr>
<td width="85%">I take attendance </td>
<td width="15%" align="center" valign="middle"><?=form_dropdown('attendance',$options, $this->validation->attendance)?></td>
</tr>
<tr>
<td>Number of Absences </td>
<td align="center" valign="middle"><input name="absences" type="text" size="3" maxlength="3" value="<?=$this->validation->absences?>"/></td>
</tr>