Form Generation Library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Form Generation Library (/showthread.php?tid=16439) |
Form Generation Library - El Forum - 12-15-2009 [eluser]dinhtrung[/eluser] Just off topic, what is the best way to implement search page? I usually do this: Code: /* controller/example */ Form Generation Library - El Forum - 12-16-2009 [eluser]macigniter[/eluser] [quote author="CtheB" date="1260928690"]What is the best way to send an email after you've filled in the form succesfully, but before the onsucces redirect? 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?[/quote] The best way would be NOT to use the onsuccess function, but rather the if ($this->form->valid) clause: Code: $this->form Form Generation Library - El Forum - 12-16-2009 [eluser]hugle[/eluser] [quote author="CtheB" date="1260928690"]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?[/quote] I'd do smth like that: Code: $this->form->submit('send') Actually you could also send mail from inside the model, but I'd do: if($this->form->valid()) { //$post = $this->form->get_post(); //$post will containt submited, and validated data. it's nice ! $this->send_mail($post); } hope this helps Form Generation Library - El Forum - 12-16-2009 [eluser]CtheB[/eluser] Oke thanx for the help, this is really clear. Maybe this should be documented better btw.. i don't need the parameter $post because $this->form->get_post() will be available in the mail method Form Generation Library - El Forum - 12-16-2009 [eluser]macigniter[/eluser] [quote author="CtheB" date="1260984194"]Maybe this should be documented better [/quote] Feel free to help :-) Form Generation Library - El Forum - 12-16-2009 [eluser]happydude[/eluser] How do I dynamically set the upload folder? I want images for each method of a controller to be saved in different folders. uploads to admin/addproduct should go to assets/products uploads to admin/addcategory should go to assets/categories uploads to admin/addbrand should go to assets/brands Any help will be appreciated. Form Generation Library - El Forum - 12-16-2009 [eluser]Mat-Moo[/eluser] [quote author="happydude" date="1260991935"]How do I dynamically set the upload folder? I want images for each method of a controller to be saved in different folders. uploads to admin/addproduct should go to assets/products uploads to admin/addcategory should go to assets/categories uploads to admin/addbrand should go to assets/brands Any help will be appreciated.[/quote] Just change the config file Code: $config=array( Form Generation Library - El Forum - 12-16-2009 [eluser]happydude[/eluser] I tried that. I got errors about the $config array not getting sent properly into the Form library. Probably because the config for teh upload path follows this order: $config['defaults']['upload']['upload_path'] I even tried: Code: $config = $this->config->item('defaults'); It still did not work. I need help on this one urgently. Form Generation Library - El Forum - 12-16-2009 [eluser]hugle[/eluser] [quote author="happydude" date="1261015740"]I tried that. I got errors about the $config array not getting sent properly into the Form library. Probably because the config for teh upload path follows this order: $config['defaults']['upload']['upload_path'] I even tried: Code: $config = $this->config->item('defaults'); It still did not work. I need help on this one urgently.[/quote] I don't understand what are you trying to do, really. You wanna upload form or what? Form Generation Library - El Forum - 12-16-2009 [eluser]Mat-Moo[/eluser] @happydude I tried that. I - got errors about the $config array not getting sent properly into the Form library. What error did you get exact? That is the correct way to do it, please look at the http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html controller, but with forms you just use ->upload(var,label,config) |