Welcome Guest, Not a member yet? Register   Sign In
Combine Edit & Input Views
#1

[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">&lt;?=form_dropdown('attendance',$options, $attendance)?&gt;</td>
</tr>
<tr>
<td>Number of Absences </td>
<td align="center" valign="middle">&lt;input name="absences" type="text" size="3" maxlength="3" value="&lt;?=$absences?&gt;"/&gt;</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">&lt;?=form_dropdown('attendance',$options, $this->validation->attendance)?&gt;</td>
  </tr>
  <tr>
  <td>Number of Absences </td>
  <td align="center" valign="middle">&lt;input name="absences" type="text" size="3" maxlength="3" value="&lt;?=$this-&gt;validation->absences?&gt;"/></td>
</tr>


Messages In This Thread
Combine Edit & Input Views - by El Forum - 01-03-2008, 09:32 AM
Combine Edit & Input Views - by El Forum - 01-03-2008, 09:59 AM
Combine Edit & Input Views - by El Forum - 01-03-2008, 10:10 AM
Combine Edit & Input Views - by El Forum - 01-03-2008, 11:51 AM
Combine Edit & Input Views - by El Forum - 01-03-2008, 12:38 PM
Combine Edit & Input Views - by El Forum - 01-03-2008, 12:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB