Welcome Guest, Not a member yet? Register   Sign In
config items inside another config file
#1

[eluser]skunkbad[/eluser]
I currently have some constants defined in a hook that are being used in a config file, but was wondering if I could alternatively use another config file. Specifically, it is the form_validation config file that I created. Some validation rules are controlling username length, password length, etc. Am I already doing all I can do?
#2

[eluser]patak[/eluser]
Hi, have you already found some solution? I am interested in it. I am solving exactly the same problem.
Jan
#3

[eluser]jamziee[/eluser]
look at the guides, you can creat other config files
#4

[eluser]patak[/eluser]
I mean this case:
Have two config files
- config.php
Code:
$config['config_item'] = "value";
- custom_config.php
Code:
$config['custom_config_item'] = "index.php/something/" . $this->config->item('config_item');
// in custom_config_item I need value from config_item from config.php
How to achieve it?
#5

[eluser]Myles Wakeham[/eluser]
[quote author="skunkbad" date="1258189827"]I currently have some constants defined in a hook that are being used in a config file, but was wondering if I could alternatively use another config file. Specifically, it is the form_validation config file that I created. Some validation rules are controlling username length, password length, etc. Am I already doing all I can do?[/quote]

I am getting a sense that you might want to stop and think about what you are trying to do, and see if addressing this in a more 'object oriented' style makes sense. What we do is to define visual forms as 'interfaces' to the classes that they are for. For example, if you have a customer class, and you define all the properties to that class, you can also define an array of properties and their rules (ie. mandatory or not, length, data type supported, etc.). We store this in a database along with the form that uses those elements, their x/y location, field lengths, types, etc. Then when I want to create a form, I just render the visual display on top of a HTML page (we use Smarty for all fields on the page, so including it on a page is relatively simple).

For validation, you can either validate on the page (ie. Javascript during data entry), validate on the client on form submission (ie. Javascript), or validate in PHP/CI when the form is brought into the web application. Of course all field values come in having been checked for XSS, etc. and loaded into an array of post fields. Then each class, before it is allowed to save its data, will have its own validation routine that checks the rules of all properties to make sure that the overall rules of the class are maintained before allowing the data to get into the database.

The problem is simply that you can't control the UI that your app will be working with. Today it might be a PC desktop browser. Tomorrow it might be a smart phone. Next week it could be a kiosk or media center on a TV set. etc. The validation has to be two fold - protect the database from incorrect or missing data coming in, and (to a lesser extent) enhance the user's experience by telling them up front when they do something wrong or don't supply all the right stuff. True to the MVC model, I think you need something that is tied to a single class for the data that achieves both of these goals, and I'd be putting that code in models as a method to the class itself.

Hope you can take something from what we do and make some use of it.

Myles




Theme © iAndrew 2016 - Forum software by © MyBB