Skip to main content

Show Posts

This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.

Messages - zac.nz

1
Questions / Remote Search Lookup - Foreign Key - Add a new row
Hello :)

I am trying to use a select field to 1) add a relation to the table it's on 2) while using the datasource from another table be able to add new rows

Example case:

Table 1: "Food" has auto-increment "ID_food" column and a varchar name column "food_name"
Table 2: "List" has auto-increment "ID_list" column and an integer column that is a foreign key of the above table "food_rel"

Table 2 Add Page: "food_rel" is using the select field property and datasource options to link to the source table 1. Remote Search Lookup is turned on.

This works perfectly, adding the relation I need in Table 2 with a searchable dropdown of all the rows in the "Food" table. However, I want to be able to add a new row in the "Food" table from within the select field on the above mentioned page.

Ideally, the user will type in a new "food_name", which then auto creates a new "ID_food", so that on "List" table it inserts the new "food_rel"

I feel like this should be possible editing a custom query for the select field and attributing the right foreign key constraints in phpmyadmin - but I just can't quite get there.

Hopefully that makes sense :)

Zac