Moodle
  1. Moodle
  2. MDL-29817

Passing attributes to advcheckbox form object triggers "undefined index" notice.

    Details

    • Database:
      Any
    • Workaround:
      Hide

      Put a bogus "group" key into the attributes array, but may have side effects.

      Show
      Put a bogus "group" key into the attributes array, but may have side effects.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_28_STABLE

      Description

      On or about line 47 of /lib/form/advcheckbox.php is the line:

      <code>
      if (!is_null($attributes['group'])) {
      <code>

      If the attributes array doesn't contain the 'group' key, an undefined index notice will be triggered. The following line should make the notice go away:

      <code>
      if (!is_null($attributes) && array_key_exists('group', $attributes)) {
      <code>

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Michael de Raadt added a comment -

            Thanks for reporting that issue and providing a fix.

            It looks like you won!

            Show
            Michael de Raadt added a comment - Thanks for reporting that issue and providing a fix. It looks like you won!
            Hide
            Rajesh Taneja added a comment -

            Hello. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

            For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

            If you have any information about this issue or a possible fix please post it here

            Show
            Rajesh Taneja added a comment - Hello. I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment If you have any information about this issue or a possible fix please post it here
            Hide
            Marina Glancy added a comment - - edited

            This is still an issue in 2.8, it's just nowhere in Moodle we use advcheckbox with attributes others than 'group' so we don't face it.

            To test apply this and open "Edit profile" form:

            --- a/user/editadvanced_form.php
            +++ b/user/editadvanced_form.php
            @@ -101,7 +101,7 @@ class user_editadvanced_form extends moodleform {
                     $mform->addElement('selectgroups', 'auth', get_string('chooseauthmethod', 'auth'), $authoptions);
                     $mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
             
            -        $mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'));
            +        $mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'), null, array('class' => 'myclass'));
                     $mform->addHelpButton('suspended', 'suspended', 'auth');
             
                     $mform->addElement('checkbox', 'createpassword', get_string('createpassword', 'auth'));
            

            Show
            Marina Glancy added a comment - - edited This is still an issue in 2.8, it's just nowhere in Moodle we use advcheckbox with attributes others than 'group' so we don't face it. To test apply this and open "Edit profile" form: --- a/user/editadvanced_form.php +++ b/user/editadvanced_form.php @@ -101,7 +101,7 @@ class user_editadvanced_form extends moodleform { $mform->addElement('selectgroups', 'auth', get_string('chooseauthmethod', 'auth'), $authoptions); $mform->addHelpButton('auth', 'chooseauthmethod', 'auth'); - $mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth')); + $mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'), null, array('class' => 'myclass')); $mform->addHelpButton('suspended', 'suspended', 'auth'); $mform->addElement('checkbox', 'createpassword', get_string('createpassword', 'auth'));

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: