I have a web form with checkboxes for Event Spaces.
The checkbox values are grabbed from one table in my database "facility_event_charges":
Let's say I check 5 and 6, "Audio Visual Equipment" and "Audio Visual Technician" and submit my form.
This will save the id(s) to a separate table that I have for that "Event Space" Let's say my "Event Space" has an ID of 63. The lookup table now has two entries for my id since I checked 2 of the checkboxes:
All is good and saved. Now, let's say I need to actually edit the charges associated with this space.
When I click edit, my webform renders the form fields BUT the checkboxes are empty!! Why? Because it is grabbing the data from my "facility_event_charges" table.
I need to compare this table data (array) with the data saved in my lookup table (array) to figure out which values are in common and render a check in those checkboxes.
Desired result in my edit space webform would have those checked
My checkbox "charges" array:
array(6) {
[1]=> string(9) "Officials"
[2]=> string(6) "Ushers"
[3]=> string(19) "Additional Staffing"
[4]=> string(16) "Special Lighting"
[5]=> string(22) "Audio Visual Equipment"
[6]=> string(23) "Audio Visual Technician"
}
My lookup table array:
array(2) {
[0]=> array(1) { ["EventCharge"]=> array(1) { ["facility_event_charges_id"]=> string(1) "5" } }
[1]=> array(1) { ["EventCharge"]=> array(1) { ["facility_event_charges_id"]=> string(1) "6" } }
}
-- I've been unsuccessful in my attempts - tried php array_intersect array_intersect_assoc array_map('array_diff_assoc')
I need to loop through the checkbox charges array and find a match from the lookup table array, when it matches, mark the checkbox "checked".
Anyone have any working examples I could test out? The checkbox charges array key is what would need to match the "facility_event_charges_id"
Aucun commentaire:
Enregistrer un commentaire