This topic is locked

different child fields based on parent record settings

5/15/2020 11:53:07 AM
PHPRunner General questions
W
wfcentral author

I have a client who wants to convert their student rosters to online. I'm trying to do this without an extreme number of tables or table views.
three tables - tbl_roster, tbl_class_type, tbl_students
instructor creates a roster in tbl_roster. There is an option in there to select which class type - this dropdown is populated from tbl_class_type.
tbl_students has the following fields - id, firstname, lastname, pass/fail, elearning, level2, level3
tbl_class_type has ID, class_name
Example data for class_type would be

1 bicycle

2 cooking

3 coding
= HERE IS WHERE IT GETS TRICKY =
if the roster is for class (1) bicycle then students added to that roster as child records only need to have id, firstname, lastname, pass/fail.
if the roster is for class (2) cooking then students added to that roster as child records need to have id, firstname, lastname, pass/fail, level2, level3
if the roster is for class (3) coding then students added to that roster as child records need to have id, firstname, lastname, pass/fail, elearning, level2, level3
So, I'm basically trying to hide fields on the student add/edit form if the parent is a certain class.
If I can't figure a way to do this with logic then the messy option is to create a different roster_view for every class and a different student_view for every class. So, I would end up with 12 views of the roster table, 12 views of the student table. I don't want to go that route because if they want to change something simple on the student form (like capture middle name) then I have to update all those views.

need2sleepDevClub member 5/15/2020

I have something similar setup and use this all day long.
The manual is great at explaining how it works.
If you are hiding fields on the fly:

https://xlinesoft.com/phprunner/docs/hidefield_js.htm
If you are hiding fields on page load:

https://xlinesoft.com/phprunner/docs/hidefield.htm

W
wfcentral author 5/15/2020



I have something similar setup and use this all day long.
The manual is great at explaining how it works.
If you are hiding fields on the fly:

https://xlinesoft.com/phprunner/docs/hidefield_js.htm
If you are hiding fields on page load:

https://xlinesoft.com/phprunner/docs/hidefield.htm


Thanks for that info - I'm guessing from looking at those I would need to make the add/edit as pop-ups or full pages. Right now I have them as inline add/edit. On the page where the rosters are there might be several different patterns going on so I can't hide all the fields on that page.

need2sleepDevClub member 5/15/2020



Thanks for that info - I'm guessing from looking at those I would need to make the add/edit as pop-ups or full pages. Right now I have them as inline add/edit. On the page where the rosters are there might be several different patterns going on so I can't hide all the fields on that page.


Not necessarily. The code has to go into those sections but will work on list pages during add/edit. You will have to create If Statements or Case to choose which ones to hide based on selection.
For example, you can use this code in the field events with JavaScript so when a value changes during edit, the fields can hide or if you need the fields to hide when the list is displayed you can use the other link in the manual.
It seems like all you need is 3 'If' statements to hide or show 3 fields during on load event.