Welcome Guest, Not a member yet? Register   Sign In
Form validation issue
#1

[eluser]Unknown[/eluser]
Hello All,

I am writing simple application with two forms:

1) add form

workflow:

- display empty form
- after submit check (using CI validation form class) all fields
- if something wrong display form again with repopulated data and error info
- if all ok put data into mysql

1) edit form

workflow:

- get data from mysql and display filled form to edit
- after submit check all fields using validation rules
- if something wrong display form again with repopulated data and error info
- if all ok update data in mysql

So far add form works good, but I have problem with edit form. I don't know how pass initial data from mysql to edit form and then allow user to edit form.

Please help me solving my problem.

Regards
Adam
#2

[eluser]webtigers[/eluser]
You need to use set_value().

Code:
<input name="address1" type="text" value="<?php echo set_value('address1', $address1); ?>" />

I like to use set_value() in conjunction with form_validation() to set the default value of the input control within the view. Be sure to load the view with the var $data->address1 within your controller.




Theme © iAndrew 2016 - Forum software by © MyBB