multiselect data not store in database

multiselect data not store in database

by shorabh gupta -
Number of replies: 2
Hi,
 
    I have add custome multiselect box in course certificate page but multi select data not store in datdabase


            $moption = array(
            'Java' => 'Java',
            'PHP' => 'PHP',
            'ASP' => 'ASP'
        );
        $select = &$mform->addElement('select', 'coursename', 'label for colors', array('red', 'blue', 'green'));
        $select->setMultiple(true);
        $mform->setDefault('coursename', 0);
        $mform->addHelpButton('coursename', 'coursename', 'certificate');

Average of ratings: -
In reply to shorabh gupta

Re: multiselect data not store in database

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If that's *all* you are doing then it's not surprising. You need to find the code that processes the form submission and store your data. You'll probably need to add a field to the database for it too!

In reply to Howard Miller

Re: multiselect data not store in database

by shorabh gupta -

Thank you for your Reply

                        Miller i was already added one field in database. i was set input type "text" or "select" then work fine but when  we use "Multiselect" that time data not store in data base.We are use moodle 2.8

( file address=>mod/certificate/mod_form.php)

$moption = array(
            'Java' => 'Java',
            'PHP' => 'PHP',
            'ASP' => 'ASP'
        );
        $select = &$mform->addElement('select', 'coursename', 'label for colors', $moption);
        $select->setMultiple(true);
        $select->setSelected('2','0');
        $mform->setDefault('coursename', 0);
        $mform->addHelpButton('coursename', 'coursename', 'certificate');

Give me your guidance. Please