Welcome Guest, Not a member yet? Register   Sign In
form set_value
#1

[eluser]jairoh_[/eluser]
i have a form that changes a title's value, but before changing changing it's value, it will have its default value shown. But when the validation of the value is invalid, i want the invalid value will still be there instead of the default value. anyone has an idea? tnx

Code:
<?php echo form_input( 'title', $default_value ); ?>
#2

[eluser]LuckyFella73[/eluser]
hi jairo

have a look at the userguide section "Re-populating the form"

http://ellislab.com/codeigniter/user-gui...ation.html
#3

[eluser]jairoh_[/eluser]
[quote author="LuckyFella73" date="1369305179"]hi jairo

have a look at the userguide section "Re-populating the form"

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

yeah but if that will happen, how can i show the default value? and the default value was static that means from a database.
#4

[eluser]LuckyFella73[/eluser]
Code:
<?php echo set_value('title', $default_value); ?>

Where $default_value is the value from db.

http://ellislab.com/codeigniter/user-gui...nreference

Scroll down a bit and see section "set_value()"
#5

[eluser]jairoh_[/eluser]
[quote author="LuckyFella73" date="1369308640"]
Code:
<?php echo set_value('title', $default_value); ?>

Where $default_value is the value from db.

http://ellislab.com/codeigniter/user-gui...nreference

Scroll down a bit and see section "set_value()"[/quote]
yeah, but my default value will be gone if i do that. correct me if i'm wrong.
yes it the invalid value will remain if i'll use set_value but how about my default value in the first load? because if i do set_value, then the default is empty.
#6

[eluser]TheFuzzy0ne[/eluser]
I'm not quite sure what the problem is here. The default value is only required the first time the form is loaded. Each time the form is submitted, the submitted value is used. So:

Code:
<?php echo form_input('title', set_value('title', $default_value)); ?>

...should work exactly as you expect it to.

Please try it, and get back to us if it's not what you expect.
#7

[eluser]jairoh_[/eluser]
[quote author="TheFuzzy0ne" date="1369320978"]I'm not quite sure what the problem is here. The default value is only required the first time the form is loaded. Each time the form is submitted, the submitted value is used. So:

Code:
<?php echo form_input('title', set_value('title', $default_value)); ?>

...should work exactly as you expect it to.

Please try it, and get back to us if it's not what you expect.[/quote]
it solved it. thank you for your post.




Theme © iAndrew 2016 - Forum software by © MyBB