I have the following tables:
-- -----------------------------------------------------
-- Table `product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `product` (
`id` INT NOT NULL AUTO_INCREMENT ,
`productName` VARCHAR(255) NULL ,
`s7location` VARCHAR(255) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `pages`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `pages` (
`id` INT NOT NULL AUTO_INCREMENT ,
`productID` INT NULL ,
`pageName` VARCHAR(255) NOT NULL ,
`isBlank` TINYINT(1) NULL ,
`pageOrder` INT(11) NULL ,
`s7page` INT(11) NULL ,
PRIMARY KEY (`id`) ,
INDEX `productID` (`productID` ASC) ,
CONSTRAINT `productID`
FOREIGN KEY (`productID` )
REFERENCES `product` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `field`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `field` (
`id` INT NOT NULL AUTO_INCREMENT ,
`pagesID` INT NULL ,
`fieldName` VARCHAR(255) NOT NULL ,
`fieldType` VARCHAR(255) NOT NULL ,
`fieldDefaultValue` VARCHAR(255) NULL ,
PRIMARY KEY (`id`) ,
INDEX `id` (`pagesID` ASC) ,
CONSTRAINT `pagesID`
FOREIGN KEY (`pagesID` )
REFERENCES `pages` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
I have gotten CRUD to work on the 'product' table.
//addproduct.php
class page_addproduct extends Page {
function init(){
parent::init();
$crud=$this->add('CRUD')->setModel('Product');
}
}
This works. but I need to get it so that when a new product is created it basically allows me to add new rows into the pages and field tables.
For example, the products in the tables are a print product(like a greeting card) that has multiple pages to render. Page 1 may have 2 text fields that can be customized, page 2 may have 3 text fields, a slider to define text size, and a drop down list to pick a color, and page 3 may have five text fields that can all be customized. All three pages (and all form elements, 12 in this example) are associated with 1 product.
So when I create the product, could i add a button to create a page for that product, then within the page i can add a button to add a new form element field?
I'm still somewhat new to this, so my db structure may not be ideal. i'd appreciate any suggestions and feedback! Could someone point me toward some information, tutorials, documentation, ideas, suggestions, on how I can implement this?