Welcome Guest, Not a member yet? Register   Sign In
Getting form data from database - input and help needed.
#1

[eluser]Kyle Johnson[/eluser]
Hello Everybody!

Lots of fun things going on with my app. I have the majority of the menu/security/control tables setup properly (I hope!) I am trying to store all of the variables for the form items within a table "mnu_task_has_field"

My old form data was all stored within php and generated as the page was loaded.

It looked like this:
Code:
$this->load->model('package_type');
$form->add_input(array(
    "type" => "select",
    "name" => "package_type_id",
    "label" => "Package Type",
    "options" => $this->package_type->dropdown()
));

It is very easy to store "type, name and label" in the database, but something dynamic like "options" makes it very difficult.

What would you think is the best way to do this? I am thinking of making the majority of the form data still be stored in the PHP files, and only selecting the ones that meet the criteria in the database (this would also allow labels to be changed easily). Since some fields (depending on user permissions) won't show up at all or might be read-only.

However, I wouldn't be quite sure how to load inputs only for the ones in the database. I mean, let's assume 'package_type_id' is in the query of fields to load. Would I then make an if statement for each item that might be on the page?

Let me know if you need more information, or if I'm doing this terribly wrong.




Theme © iAndrew 2016 - Forum software by © MyBB