Welcome Guest, Not a member yet? Register   Sign In
Central form handeling
#4

[eluser]GrahamDj28[/eluser]
[quote author="CroNiX" date="1351012590"]How is CI supposed to override default web behavior by not submitting the form to the URL in the Action attribute?
[/quote]

No need to override default web behavior. Every request is routed through the index.php and the URI class is always called. In my CI setup I only have 1 front end controller and 1 back end controller. I have extended the URI class to filter out extra params that can be set in the URL. You could say all my URLs are virtual and they all get routed through 1 of the controllers depending on the call.

That being said, just because the form has an action URL does not mean that is has to be processed by that "page". A check can be done in the controller where the request is handled to see if a form has been posted.

I figured this out after I posted the question and so I have centralized the handling of forms. I also got fed up with writing controllers for every page, and have setup a kind of HMVC where modules do the real stuff and return partial views. I like to keep files that have a relationship together in a single package so moving them to a new project is no big deal. To have the request execute the proper module and methods the _remap functions is used as PhilTem mentioned in his reply.

And the redirecting is only done on success and on failure the re-populated form with errors is returned.


Messages In This Thread
Central form handeling - by El Forum - 10-23-2012, 05:26 AM
Central form handeling - by El Forum - 10-23-2012, 10:16 AM
Central form handeling - by El Forum - 10-23-2012, 11:19 AM
Central form handeling - by El Forum - 10-23-2012, 12:54 PM
Central form handeling - by El Forum - 10-23-2012, 01:19 PM
Central form handeling - by El Forum - 10-23-2012, 01:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB