Passing default values to a new subform

wallaby9

Member
You are using DaDaBIK version 8.0-Lerici enterprise, installed on 04-25-2017 (installation code: ), the latest version of DaDaBIK is 8.0-Lerici released on 04-24-2017 / You are runnning the last release of DaDaBIK
PHP Version: 5.5.9-1ubuntu4.21 / mysql version: 5.5.55-0ubuntu0.14.04.1 / Web server: nginx/1.10.3
Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36


Good evening.

I am trying to create a Contracts form. Each Contract can have one or more Flights.

In tblFlights table there is a key to the tblContracts table to say which Contract the Flight belongs to.

I have set up the Contracts form with a subform to display all the Flights for that Contract and it works great.

But when I click "Create new item" on the Flights subform of the Contracts form, I need to auto-fill the idContract field.

How is this done please?

(and is it possible to fill more than just the id field, can you use whatever the method is, to fill any field?)


Thank you
 

wallaby9

Member
Sorry to reply to my own message but I have just worked out how to achieve this for the main ID field, using the "select_single" field type.

However I still can't figure out how to pass other default values to the new entry.

I note that the HTML for the "Add new item" button passes these parameters so I guess I need some way to pass others in a similar fashion:

[pre]
http://mysite.com/db/index.php?function=show_insert_form&tablename=tblFlights&master_table_name=tblContracts&master_table_function=edit&master_table_where_field=idContract&master_table_where_value=198&is_items_table=1&set_field_default_value=1&default_value_field_name=idContract&default_value=198
[/pre]
 

eugenio

Administrator
Staff member
Hello,
there isn't any built-in method to set default values passings querystring parameters, you can, however, fill the "default value" parameter in form configurator. Can that help?

Best,
 

wallaby9

Member
Probably not, if it can't change dynamically, for example with something like

[pre]
= dadabik_var some_field_value dadabik_var
[/pre]

I will have to think more about this. Perhaps I can fill the values in at a before_update trigger (I've not looked at triggers in detail though have watched your brief video so I know that they exist).
 

eugenio

Administrator
Staff member
A before update trigger is executed only before the update execution but after the click on "SAVE" so it is not suitable for your needs.

If you explain your use case in details, maybe there is a workaround.

Best,
 

wallaby9

Member
Thank you Eugenio I appreciate your time.

However I think my need to do this is only because of a shortcoming in the schema design, so I've decided to take a little longer over it and try fixing it from that angle.

The schema is a direct conversion from an Access database, which had a multitude of fixes and bodges applied.
 
Top