Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27145

Undefined index: optional in lib/form/dateselector.php on line 169

    Details

    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      developing a module
      I wrote in a form:

      $mform->addElement('date_selector', $fieldname, get_string($fieldname.'_label', 'collection'), array('startyear' => 1900));

      At run time I got the following notice from xdebug:

      Undefined index: optional in /Applications/MAMP/htdocs/moodle20/lib/form/dateselector.php on line 169

      Actually, in moodle20/lib/form/dateselector.php on line 169 I found

      if($arg[2]['optional']) {

      and with my call, $arg[2] is:

      Array
      (
      [startyear] => 1900
      )

      only. Is this a bug?

        Gliffy Diagrams

          Activity

          Hide
          samhemelryk Sam Hemelryk added a comment -

          Linked PULL-649 (MOODLE_20_STABLE) and PULL-650

          Show
          samhemelryk Sam Hemelryk added a comment - Linked PULL-649 (MOODLE_20_STABLE) and PULL-650
          Hide
          samhemelryk Sam Hemelryk added a comment -

          This is a bug caused by code that assumes optional has been specified.
          Essentially other than the fact that you get the notice things should function correctly.

          I've created two pull request one for stable and one for dev to see this tidied up now.

          Cheers
          Sam

          Show
          samhemelryk Sam Hemelryk added a comment - This is a bug caused by code that assumes optional has been specified. Essentially other than the fact that you get the notice things should function correctly. I've created two pull request one for stable and one for dev to see this tidied up now. Cheers Sam
          Hide
          daniss Daniele Cordella added a comment -

          tested, works fine. Thanks Sam!

          Show
          daniss Daniele Cordella added a comment - tested, works fine. Thanks Sam!

            People

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

              Dates

              • Created:
                Updated:
                Resolved: