Value not get in $mform->get_data();

Value not get in $mform->get_data();

by R K -
Number of replies: 3

Hi Team,

I have a form in the form select categories. As per categories, I want to select course to resolve this problem I am using ajax to fetch course after select categories. 

for categories

 $mform->addElement('select', 'categories', 'Categories', $categoriesarray);

and for course 

$mform->addElement('select', 'course', 'Course', $coursearray);

use addElement.

But after fetch value through ajax in the course element.

It is showing all value successfully. 

But after click on View button. 

$this->add_action_buttons(true, 'View');

couse value not pass in view page.

stdClass Object
(
    [categories] => 2
    [submitbutton] => View
)
what I do, please tell me.

thanks for reply.

Average of ratings: -
In reply to R K

Re: Value not get in $mform->get_data();

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

When you generate the 'course' element, does it contain every possible course value?

A common problem with filling in select elements via AJAX is that Moodle validates the submitted select value against the possible values that are present in the definition. That means that any values that are not part of the definition are thrown away as invalid, before being returned.

Average of ratings: Useful (3)
In reply to Davo Smith

Re: Value not get in $mform->get_data();

by R K -

Hi Davo

Thanks for reply,

I need help for resolve this problem. 

In reply to Davo Smith

Re: Value not get in $mform->get_data();

by R K -

Hi Davo

It is possible without ajax changes my course as per categories in form. 

 

Average of ratings: Useful (1)