Hi,I am new to the Yii framework, I am developing an application in which user can create competitions and other users can submit files to that competitions. When creating a competition user can specify the type of files the participants can upload and if it is mandatory or not. Following is the database structure for custom fields defined by the competition creator and the custom data submitted by the participants. Here the fieldType represents four filetype - 1 => Image, 2 => Document, 3 => Video, 4 => Audio.
CREATE TABLE IF NOT EXISTS `tbl_custom_fields` (
`customFieldId` int(50) NOT NULL AUTO_INCREMENT,
`competitionId` int(50) NOT NULL COMMENT 'CONSTRAINT FOREIGN KEY (competitionId) REFERENCES tbl_competitions(competitionId)',
`fieldLabel` varchar(255) NOT NULL,
`fieldType` int(5) NOT NULL,
`required` int(1) NOT NULL,
PRIMARY KEY (`customFieldId`)
);
CREATE TABLE IF NOT EXISTS `tbl_custom_data` (
`customDataId` int(50) NOT NULL AUTO_INCREMENT,
`submissionId` int(50) NOT NULL COMMENT 'CONSTRAINT FOREIGN KEY (submissionId) REFERENCES tbl_submissions(submissionId)',
`customFieldId` int(50) NOT NULL COMMENT 'CONSTRAINT FOREIGN KEY (customFieldId) REFERENCES tbl_custom_fields(customFieldId)',
`value` varchar(255) NOT NULL,
PRIMARY KEY (`customDataId`)
) ;
I have created the curd functions using the Gii tool. I want to show the submission form to the user according to the fieldType defined for each competition and , for example it will be Video,Document and Image and validate the file extensions for each fields and also required fields.I tried different approaches but unsuccessful in creating a form and its action with proper Yii type validation and insertion. Can anybody please share some sample code or suggest any solution for this?
Thanks