lundi 16 mars 2015

CakePHP populate checkboxes dynamically

currently i am using CakePHP 2.6 and i have 2 tables and a many to many join table:



CREATE TABLE IF NOT EXISTS `iam-test_db`.`accesses` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`location_id` INT UNSIGNED NOT NULL,
`facility_id` INT UNSIGNED NOT NULL,
`department_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),

CREATE TABLE IF NOT EXISTS `iam-test_db`.`systems` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`facility_id` INT UNSIGNED NOT NULL,
`name` VARCHAR(60) NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_systems_facilities_idx` (`facility_id` ASC),
CONSTRAINT `fk_systems_facilities`
FOREIGN KEY (`facility_id`)

CREATE TABLE IF NOT EXISTS `iam-test_db`.`accesses_systems` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`access_id` INT UNSIGNED NOT NULL,
`system_id` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_accesses_systems_accesses`
FOREIGN KEY (`access_id`)
CONSTRAINT `fk_accesses_systems_systems`
FOREIGN KEY (`system_id`)


I've created succesfully dependent populating dropdowns for facilities and departments and currently listing all systems as checkboxes.


Now i want the checkboxes also be dependent, from which facility i choose. But atm i have no good idea how to make it. I think i have to use javascript/jquery.


I'm thinking about displaying a button and on click a popup window appears with the facility dependent systems. Is this the right way or do you have any better ideas ??


Thanks :-)





Aucun commentaire:

Enregistrer un commentaire