Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Remote Search Lookup - Foreign Key - Add a new row (Read 738 times) previous topic - next topic

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

 

Re: Remote Search Lookup - Foreign Key - Add a new row

Reply #1
@zac.nz‍ currently phprad configuration does not support that, but phprad has an option to allow you to store whatever is entered on the select input on the current page table if you set UseCustomSelect to true.