Cascaded select_single with disabled parent field

DAF ID3000

New member
Hi all.
I'm facing a problem I'm sure somebody has already dealed with.

I have basically a 'Customer', 'Employees' and 'Department' tables.
'Department' has a foreign key ('dep_customer' field) linked to 'Customer' so I can maintain a list of available departements per customer.
In the 'Employees' table, I have of course a foreign key ('emp_customer' field) linked to 'Customers' but also a foreign key ('emp_dept' field) linked to 'Departement'.
When I set up the 'Employees' form in Dadabik, I chose SELECT_SINGLE field type for both 'emp_customer' and 'emp_dept' fields, with cascade relationship between them.
In the INSERT form, everything is fine, the 'emp_dept' combo is populated upon 'emp_customer' update, great job, thanks to you Eugenio ;-) !

In the EDIT form, I don't want users to be able to change the 'emp_customer' value (indeed an employee can't be reaffected to another customer in one clic) so I have chosen 'Yes but disabled' (I think it's the source of my problem) for 'emp_customer' field in EDIT section on PERMISSIONS page.
BUT, I need users to be able to change departement affectation for the employees: that means full access to 'emp_dept' SELECT_SINGLE field...

With this configuration, users can't save any update to 'Employees' table anymore ! I get an empty page on Dadabik and these lines in debug.log:
PHP Warning: Undefined variable $dropdown_options_ar in .../include/business_logic.php on line 0
PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in .../files/include/business_logic.php:0


I've checked everything works well if I remove Cascade relationship between SELECT_SINGLE fields or if I allow full access on the EDIT form to the 'emp_customer' field.

I don't see any simple workaround.
Any help will be greatly appreciated.
KR
--
Gilles
 

DAF ID3000

New member
If someone is facing the same problem, I found a workaround by switching 'Yes but disabled' to 'Yes' for 'emp_customer' field, and by adding a custom_required_function which hides the 'emp_customer' field according to user rights.

I know it has nothing to do with Dadabik, but it's not the first time it drives me crazy and I have never understood (but IMHO it's a lack of HTML since the beginning) why disabled fields values are not posted upon form validation.
 
Top