Form Generation Library |
[eluser]CtheB[/eluser]
What is the best way to send an email after you've filled in the form succesfully, but before the onsucces redirect? Code: $this->form->submit('send') Should you do it in the model? Or like this? Code: $this->form->submit('send') Is it possible to add an error to the form in another method in the controller? Are there any other possibilities to handle the email? What is the best option to go with?
[eluser]Mat-Moo[/eluser]
I'm having a blank moment, please someone put me out of my misery! I'm trying to do a search form, user selects data, once submitted I then run a search, re-display the form with the search (table) underneath... So there is no onsucess, no model, but I did add a validate. Now the form once send is reporting Valid, and I can do a search, but once the form is regenerated the selected search data is lost. How can I get the search data back in the form... Code: $this->form // then we fill the form with elements
[eluser]happydude[/eluser]
Quote:What is the best way to send an email after you’ve filled in the form succesfully, but before the onsucces redirect? Methinks if you wanna use it in another function, just reference it (&form just like you would in a model. But really, I think it makes more sense to use ->validate() and make a $this->form->valid check, send the email within the construct, set a different error message for the email (you can set it in teh flashdata to be displayed).
[eluser]seanloving[/eluser]
@Mat-Moo - does this thread address your problem? http://ellislab.com/forums/viewthread/103956/ -SL
[eluser]CtheB[/eluser]
i already thought about that, but i don't think that is the best way. Because you will call the validation twice, 1 time in the submit/onsucces, and 1 time for the email. There must be a better way to do it. Anyone some ideas about this??? [quote author="happydude" date="1260936335"] Quote:What is the best way to send an email after you’ve filled in the form succesfully, but before the onsucces redirect? Methinks if you wanna use it in another function, just reference it (&form just like you would in a model. But really, I think it makes more sense to use ->validate() and make a $this->form->valid check, send the email within the construct, set a different error message for the email (you can set it in teh flashdata to be displayed).[/quote]
[eluser]seanloving[/eluser]
@Mat-Moo I tested that this works to preserve the select item after posting. Code: ->select('fstatusmember', array( 'one' , 'two'), 'Membership type',$this->input->post('fstatusmember'))
[eluser]CtheB[/eluser]
Hi mat-moo, ofcourse i can try to help you, if you try to help me too and have a look at my topic For your case, its really simple: Change this code: Code: // correctly finish the form { start } Into this: Code: // correctly finish the form { start } And add this function to your account controller: Code: function succes() Now you have your form and the data in a view, i think you know yourself how to finish this code now you really shouldn't reload the same form, go with an extra 'succes' page... [quote author="Mat-Moo" date="1260933734"]I'm having a blank moment, please someone put me out of my misery! I'm trying to do a search form, user selects data, once submitted I then run a search, re-display the form with the search (table) underneath... So there is no onsucess, no model, but I did add a validate. Now the form once send is reporting Valid, and I can do a search, but once the form is regenerated the selected search data is lost. How can I get the search data back in the form... Code: $this->form // then we fill the form with elements
[eluser]macigniter[/eluser]
[quote author="happydude" date="1260915941"]Does Form::get_post() automatically trim and xss_clean data? I'd like to know because I'll start writing documentation for the remaining parts tommorow.[/quote] Both: no. I turned off xss_clean due to your &DEV;_0887& problem
[eluser]dinhtrung[/eluser]
[quote author="CtheB" date="1260940888"]Hi mat-moo, Code: // correctly finish the form { start } And add this function to your account controller: Code: function succes() Is it work? I think the form object in success method and the one activate it won't be the same. Will form elements be preserved if you use redirect as the callback to handle the form data? @matmoo : Just write another model, or a function in your model, and call it from the main function of your model to handle the form data is enough, I think. |
Welcome Guest, Not a member yet? Register Sign In |