EditMode / FK gives me index instead of item - RESOLVED

Talk about foreign keys

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

daviddelmonte
Master
Master
Posts: 159
Joined: Feb 23rd, '10, 15:06

EditMode / FK gives me index instead of item - RESOLVED

Postby daviddelmonte » Jun 28th, '10, 15:38

I have a general table and a details table.
The general table only has two fields, an ID and a table name. This table contains things like "Cameras", "Lenses", "F-stops", etc.
The detail table has four fields, ID, General Table ID, Item name, and Notes. This contains items like "Nikon", "Canon",
The tables look ok in myphpAdmin.

I'm trying to get the item name from the details table as a drop down to enter in my main db.
So I call the elements as below.

Here is an example from each:

Edit Mode:

Code: Select all

// CAMERA

"camera_body" =>array(
"req_type"=>"st",
"header"=>"Camera Body",
"unique"=>false,
"type"=>"enum",
"width"=>"150px",
"operator"=>true,
"default"=>"" ),

// LENS

"lens" =>array(
"req_type"=>"st",
"unique"=>false,
"header"=>"Lens",
"type"=>"enum",
"width"=>"150px",
"operator"=>true,
"default"=>"80mm" ),


Foreign Key:

Code: Select all

// CAMERAS

"camera_body"=>array(
"table"=>"valueTableDetails",
"field_key"=>"table_id",
"field_name"=>"item",
"view_type"=>"dropdownlist",
"condition"=>"table_id=1",
"order_by_field"=>"",
"order_type"=>"ASC",
"on_js_event"=>""),


// LENS

"lens"=>array(
"table"=>"valueTableDetails",
"field_key"=>"table_id",
"field_name"=>"item",
"view_type"=>"dropdownlist",
"condition"=>"table_id=2",
"order_by_field"=>"",
"order_type"=>"ASC",
"on_js_event"=>""),


I can see the items in the dropdown elements in Edit mode, but selecting "Nikon" for example, I get the table-id posted in the db.

I cannot see what I'm messing up..

daviddelmonte
Master
Master
Posts: 159
Joined: Feb 23rd, '10, 15:06

Re: EditMode / FK gives me index instead of item - RESOLVED

Postby daviddelmonte » Jun 28th, '10, 19:22

Scratched my head till I got it:

The field key was wrong. See below..

Code: Select all

// CAMERAS

"camera_body"=>array(
"table"=>"valueTableDetails",
"field_key"=>"item",
"field_name"=>"item",
"view_type"=>"dropdownlist",
"condition"=>"table_id=1",
"order_by_field"=>"",
"order_type"=>"ASC",
"on_js_event"=>""),


Return to “Field type: "foreign key"”