I have encountered two issues with the widget:type=grid tool that I haven't been able to figure out:
1) Sometimes it inserts a bad value of "0" into the database when a new row in a one-to-many field is created and when "Please Select ...." is accidentally selected on previous row.
2) Once a sub-form value is created and saved, there doesn't appear to be a way in the GUI to delete it unless you go to a sub-tab.
Let me provide more detail...
Currently, my fields.ini code is:
- Code: Select all
[SubType1]
order=10
transient=1
relationship=SubType1
widget:type=grid
widget:columns="SubType1ID"
And my code in relationships.ini is:
- Code: Select all
[SubType1]
tblProductSubType1.ProductID = "$ProductID"
If I am adding a new entry in the Product table, I can add multiple SubType1s for a given Product. I can keep on selecting new SubType1s, and new dropdown menus keep on appearing (which is great!). However, if I change a previous SubType1 value back to "Please Select...", then a value of 0 gets inserted into my tblProductSubType1 table. Instead, it just shouldn't insert a row.
I realize that by clicking the red "X" things I can get rid of the bad rows before clicking "Save", however it still is troublesome that I can pollute my database with bad values. I tried using form validation to catch this but didn't have success.
The second problem is probably just a feature request - it would be great to be able to dynamically delete these sub-form values after they are saved to the database! The widget:type=grid is great for dynamically adding records, but I can't seem to get it to allow me to dynamically delete records! There are probably some reasons why this isn't allowed. If dynamic deletion isn't possible, it could be possible to put a little check box next to each records that said "Delete?" and allowed you to delete them after save.
Thanks!!