Welcome Guest, Not a member yet? Register   Sign In
example of CRUD w/form_validation
#6

[eluser]Paul Hernández[/eluser]
Hi:

I'm writting a form tu add/edit data.

To load the values of the fields in edit mode I loaded first from the database in the controller and then passing them to the view. In the view file I'm using the set_value function to populate the fields in this way:

Code:
<input type="text" name="urljornada" id="urljornada" value="<?php echo set_value('urljornada', @$url) ?>" class="myinputstyle"/>

If the form is loaded for the first time, the fields use the default value (2nd parameter of the set_value method).
If the form validation fail, the field value suppose to be the first parameter of the set_value method. The problem is the 2nd parameter throw an error because the variable is not present when the form is reload due to a validation failure. I followed the advice in this thread and putted a "@" preceding the variable name and that solved it, but is this the best/correct/intelligent/shorter/elegant way to do it?

I'm using CI2

Regards


Messages In This Thread
example of CRUD w/form_validation - by El Forum - 01-12-2011, 08:17 PM
example of CRUD w/form_validation - by El Forum - 01-13-2011, 01:51 AM
example of CRUD w/form_validation - by El Forum - 01-13-2011, 05:11 AM
example of CRUD w/form_validation - by El Forum - 01-13-2011, 05:26 AM
example of CRUD w/form_validation - by El Forum - 01-13-2011, 05:26 AM
example of CRUD w/form_validation - by El Forum - 03-16-2011, 02:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB