anchor function- how to pass 10 values back to controller class ? |
[eluser]cinewbie81[/eluser]
Hi all, In a Email Setting Form i have 2 buttons:. "SAVE" button -> anchor('email/save', 'Save') "SEND" button -> anchor('email/send', 'Send') I have 10 fields in my EMail Setting form as well. How can i pass these 10 fields value to my Email Controller class ? The url will looks weird if i do something like this: "SAVE" button = anchor('email/save/field1/field2/field3..../field10'); "SEND" button -> anchor('email/send/field1/field2/field3..../field10', 'Send') I know it can be done using post method if i have only 1 button. But now i have 2 buttons, i cant determine which one should i use : form_open('email/send'); or form_open('email/save'); Help !!
[eluser]gtech[/eluser]
have you thought about using session data? see sessions documentation especially the Adding Custom Session Data section. It saves you having to pass data around the urls I am also sure you can have two submit buttons in one form.
[eluser]cinewbie81[/eluser]
Yeh i can use two submit buttons in one form .. but how can the system tell if user click "SEND" button it will execute form_open(’email/send’), and execute form_open(’email/save’) when "SAVE" button is clicked ??
[eluser]schnoodles[/eluser]
You could always handle that in your controller like [code] if ( $this->input->post('save) ) // do this else // do that [code]
[eluser]cinewbie81[/eluser]
hi schnoodles, i guess u misunderstood what i said, let me explain in details: Email controller Code: <?php Email view form Code: <?php $this->load->view("header"); ?> When user click at the save button, i want the system to pass the 10 field values to save function in controller When user click at the send button, i want the system to pass the 10 field values to send function in controller Solution: a) Anchor function anchor(’email/save/field1/field2/field3/../field10’) anchor(’email/send/field1/field2/field3/../field10’) Anyway, it make my URL looks ugly. b) POST we can call $this->input->post('field1') easily from our controller class, but in email setting form we don't know whether to use <form method="post" action="http:/www.your-site.com/index.php/email/send" /> or <form method="post" action="http:/www.your-site.com/index.php/email/save" /> as our form action in advance Any alternative way ? Help !
[eluser]xwero[/eluser]
If you want to save or send data it's best to use a post form. Instead of sending them directly to different functions give the buttons a name and set up your controller accordingly Code: //html
[eluser]Référencement Google[/eluser]
Absolutely not sure about my answer, but maybe should you make some tests with serialize / unserialize?
[eluser]cinewbie81[/eluser]
Hi xwero, I do it according to your suggestion. When user click at button 'save', it echo me the value <b>send_end</b>. (It suppose to be save_admin@yahoo.com_end When user click at button 'send', it echo me the value <b>save_end</b>. (It suppose to be send_admin@yahoo.com_end It seems to me that the system can't detect the value of emailaddres. Any idea ? Btw, following is my codes: Controller class for email setting Code: <?php> form_emailsetting.php - Form for email setting Code: <?php echo form_open('emailsetting/validation');?>
[eluser]xwero[/eluser]
I see you don't close your form using an echo maybe that is the problem?
[eluser]cinewbie81[/eluser]
Problem solved .. Thanks a lot xwero .. i really meant it .. ! |
Welcome Guest, Not a member yet? Register Sign In |