From: Bharat M. <bh...@me...> - 2013-04-17 19:54:27
|
I agree. Forms are inherently tied to the browser so they belong in the controller. The main reasons why we used helpers for this were to avoid the problem that all functions in controllers are directly accessible so now with K3 we can put them back in the controller. On Wed, Apr 17, 2013 at 7:20 AM, Shad Laws <sh...@sh...> wrote: > Hey everyone, > > I'm starting to gear up for the big K2 Forge -> K3 Formo conversion, and > have a question: would it bother anyone to put all form definitions in > controllers? > > In Gallery 3.0.x, there are two patterns I see: > - form validation/implementation in controller, form definition in > controller (often in a private function that's called by the main > controller action) > - form validation/implementation in controller, form definition in helper > (in a public function that's called by the main controller action) > > Personally, I prefer the former configuration. While I realize it may bug > a few folks to have all form info in controllers (form handling with pure > MVC separation isn't straightforward), I find it simpler to have the code > that defines the fields sitting in the same place as the code that uses > those field definitions to validate and/or implement user input. > > Also, in K3 we don't need to make controller functions private to hide > them from url access. We can leave them public and give them non-action > names. > > So, my proposal is to do something like this in the controller: > > public function action_edit() { > $form = $this->get_edit_form(); > // spit out the form > } > > public function action_save() { > // validate the form, process its inputs. > } > > public function get_edit_form() { > // define and return the form, whose action is save > return $form; > } > > Thoughts? > > Take care, > Shad > > > ------------------------------------------------------------------------------ > Precog is a next-generation analytics platform capable of advanced > analytics on semi-structured data. The platform includes APIs for building > apps and a phenomenal toolset for data science. Developers can use > our toolset for easy data analysis & visualization. Get a free account! > http://www2.precog.com/precogplatform/slashdotnewsletter > __[ g a l l e r y - d e v e l ]_________________________ > > [ list info/archive --> http://gallery.sf.net/lists.php ] > [ gallery info/FAQ/download --> http://gallery.sf.net ] > |