saltcorn icon indicating copy to clipboard operation
saltcorn copied to clipboard

improve two-level-select enormously with defining join-field as top-level and prevent changing value of thar toplevel

Open HFolkertH opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Case of Orders for a certain Category and then adding Orderlines where you can only add IItems from that same Category as set in the Order. So the Order shouls set the top-level field of the two-levl-select in the linked Orderlines. And users should not be able to change to top-level of the two-level-select.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

HFolkertH avatar Feb 03 '24 16:02 HFolkertH

I think this can be done using an form action. I used it and it works well. There is a help menu on the Edit view that describes how to create a form action.

From the release of 0.9.0 It is now also possible to use an action inside a form to change the field contents. This is done by returning set_fields from an action. You can use this to fill in a selected template or to set calculated (but editable) values

cfredericksen avatar Feb 05 '24 04:02 cfredericksen

hello @cfredericksen,

Thanks for helping me with this. I have added a form action on my edit view to prefill a Select fieldtype for ordered_item but alas with no the result I hoped for.

image

It shows all the Items in my table instead of test-texts vCPU02 and vCPU03. So I guess I am making some mistake here. Can you give a clue?

tia Folkert

HFolkertH avatar Feb 07 '24 16:02 HFolkertH

Here is my example, hopefully this will help.

I have a "New Job" Edit View. In this Edit View, I have a 2 Fields with a select view. When a user selects "Client", it will limit the list for possible jobs. To do that that: I add code, see below, to the Where box in the field of a select view (if you click the ? next to Where, it will show the possible choices)

client == $client

Keep in mind, I have two tables connected via keys that make the lookup possible. Also, often times when I am having trouble its bc I structured my table relationship incorrectly.

cfredericksen avatar Feb 07 '24 17:02 cfredericksen