Welcome Guest, Not a member yet? Register   Sign In
Repopulate the form value
#1

[eluser]rafiqasad[/eluser]
Hi, I need little help that how to repopulate the values after form validation. Suppose we have a field "name" which take a default value from database
Code:
<?php echo form_input('name', $data['name']); ?>
Suppose user put some data in it that violate the validation rule
For repopulating for value codeigniter provide code
Code:
<?php echo form_input('name', set_value('name')); ?>
Now i am confuse how to trigger between setting the values of name
Can some one help me in this regard
#2

[eluser]danmontgomery[/eluser]
http://ellislab.com/codeigniter/user-gui...ation.html

Quote:set_value()

Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function. The second (optional) parameter allows you to set a default value for the form.

Code:
<?php echo form_input('name', set_value('name', $data['name'])); ?>
#3

[eluser]Higher Ground Studio[/eluser]
Or you could just use ajax and not worry about it.
#4

[eluser]danmontgomery[/eluser]
[quote author="Higher Ground Studio" date="1279242961"]Or you could just use ajax and not worry about it.[/quote]

You're not actually suggesting using client side validation as a replacement for server side validation...?
#5

[eluser]rafiqasad[/eluser]
Thanks for reply but if your provide default value as database value , then if user provided data volatile the validation rule then how to set the posted value of the field?
#6

[eluser]danmontgomery[/eluser]
[quote author="rafiqasad" date="1279244822"]Thanks for reply but if your provide default value as database value , then if user provided data volatile the validation rule then how to set the posted value of the field?[/quote]

On the first load it will show the default ($data['name']), if any data has been posted it will show that value instead. This is the entire purpose of the set_value() function... Please read the user guide.
#7

[eluser]Higher Ground Studio[/eluser]
[quote author="noctrum" date="1279243039"][quote author="Higher Ground Studio" date="1279242961"]Or you could just use ajax and not worry about it.[/quote]

You're not actually suggesting using client side validation as a replacement for server side validation...?[/quote]

I am saying that you use ajax to send the form to a the php script that validates and then send back error/success messages
#8

[eluser]starang[/eluser]
[quote author="Higher Ground Studio" date="1279252431"][quote author="noctrum" date="1279243039"][quote author="Higher Ground Studio" date="1279242961"]Or you could just use ajax and not worry about it.[/quote]

You're not actually suggesting using client side validation as a replacement for server side validation...?[/quote]

I am saying that you use ajax to send the form to a the php script that validates and then send back error/success messages[/quote]

I agree...I don't see anything wrong with using AJAX as the middle man for this. I'm not sure why the previous replier found an issue with this suggestion...just because AJAX techniques handle the transaction doesn't mean there is no server-side validation taking place.
#9

[eluser]rafiqasad[/eluser]
Thank you very much Smile It solve my problem




Theme © iAndrew 2016 - Forum software by © MyBB