Normally you can’t have more than one field per model attribute / field database.
What your code does is generate as many checkboxes named ‘(your-model-name)_course_name’ as there are records in CourseDetail model’s table; that’s wrong as per HTML standards, and will mess up with Yii’s validation Javascript and also the form action since it will find several items with the same name in $_POST array.
That said, I don’t really understand what you’re trying to do. Outside CourseDetail model, what other related table(s) do you have? Do you have a one-to-many or many-to-many relationship in the database?
i have genrate check box of the course_name.the id is a primarykey and auto increment.then i have create checkbox is dynamically then i have use this course_name into contact form. then i checked any checkbox then how they are store the checkbox value into database.
my another contact databse is:-
id int(3)
name varchar(50)
date date
email varchar(40)
qualification varchar(20)
ref_from varchar(40)
intrested_course varchar(20) // i want to store checked checkbox value into this filed
intrested_in_joining varchar(10)
How to stored the course_name checkbox checked value into the intrested_course field.
Ok, so I understand you have two tables and models, one for the courses (I will call it “Course”), one for the potential trainees (I’ll call it “Contact”).
I believe that like you want just one course per trainee, if I understand correctly you table schema. IN that case, I’ll advise you to use option (radio) buttons instead of checkboxes.
Here table course_detail field "course_name" are stored into the contact tables "intrested_course".they are checkbox.how to store the value into the database.
i haqve do the inquiry for for the institute.
this inquiry form are mail and stored into the database.the mail function is already i have done but the checkbox checked value are not stord into database and mail function.