[eluser]purpleparasol[/eluser]
I have coded two forms and please note **they are behaving as I would like**, but I don't know why. If I put the code here can someone explain why it is working.
I have a simple form on a view, with its own controller like this
Code:
<?=form_open('newslettersignup'); ?>
<h2>Newsletter Signup</h2>
<label>Name</label>
<input type="text" name="name" maxlength="25"></input>
<label>Email</label>
<input type="text" name="email" maxlength="50"></input>
<label>Country</label>
<?=$this->load->view("include-country-dropdown");?>
<input class="button" type="submit" value="sign up"></input>
<?=form_close() ?>
When someone fills in the values and clicks on the submit button, it goes to a different controller called newsletter signup which shows another form like the one below.
Code:
<?=form_open('newslettersignup'); ?>
<h2>Newsletter Signup</h2>
<label>Name</label>
<input value="<?=set_value('name');?>" type="text" name="name" maxlength="25"></input>
<label>Email</label>
<input value="<?=set_value('email');?>" type="text" name="email" maxlength="50"></input>
<label>Country</label>
<?=$this->load->view("publicuser/include-country-dropdown");?>
<input class="button" type="submit" value="Send">
<?=form_close()?>
The second form contains the values for name, email and country that the first form contained, which is what I wanted to happen. My question is - how did I do this? What is making the second form contain the same values as the first form when I don't think I've done anything explicitly to make this happen. Is it the set_value call?
Apologies if this sounds daft, but I've done what I want to do with no idea how I did it. Not really sure what set_value does when the values were in another, separate form.