Welcome Guest, Not a member yet? Register   Sign In
What do you do with your config arrays?
#1

[eluser]Bramme[/eluser]
Hey all,

I'm looking for some input:

I'm building a website and the frontend is based on one controller. I've got a contact page, a news page with pagination etcetera etcetera. This means that my controller is littered with arrays like $fields, $rules, $pagination_config, $data['form'] (to use with the form helper) and so forth.

I've put the largest part of my $pagination_config in it's separate config file, same goes for email and so on, but I was wondering: do you put your $rules $fields and $form array in a separate file too?

I guess I could make a helper that simply returns those arrays, but I was wondering if there was a better way to do this.
#2

[eluser]Bramme[/eluser]
nobody got anything to say about this?
#3

[eluser]Yash[/eluser]
I use this for general and common settings...
#4

[eluser]Crimp[/eluser]
I put the arrays for validation in private functions at the bottom of the controller. This practice cuts down on the amount of smaller helpers and configs and keeps the controller code minimal for easier reading. Instead of long arrasy, the controller method gets one line:

Code:
$this->_form_validation($action);

If the same form view is used for insert/update actions, I pass in an $action varriable and set the fields accordingly, if any changes are needed, in the private function.
#5

[eluser]xwero[/eluser]
Validation should be in a different file, then the code in the controller almost reduces to the minimum. But for that to happen you need to customize the CodeIgniter.php file. The same thing is possible if you want to keep the display manipulations of the data out of the models.

Basically it is creating intercepting layers. The validation is called before the controller loads and the viewdata layer is called between the controller and view.




Theme © iAndrew 2016 - Forum software by © MyBB