← Back to team overview

mahara-contributors team mailing list archive

[Bug 1787493] [NEW] Unable to have both "" and "0" as options in a select form and have "" the selected one

 

Public bug reported:

This is due to the function pieform_element_select_render_options() not
checking on type

the line
   $stringvalue = !is_array($values) && $key == $values;

needs to be
   $stringvalue = !is_array($values) && $key === $values;

To test create a select field with options like this:

'options' => array("" => get_string('nocategoryselected', 'mahara')) +
array_combine(range(100, 0), range(100, 0)),

 and have

'defaultvalue' = '',


Expected:  we should have the nocategoryselected option displayed
Currently: we have the option "0" selected

** Affects: mahara
     Importance: High
     Assignee: Robert Lyon (robertl-9)
         Status: In Progress

** Changed in: mahara
    Milestone: None => 18.10.0

** Changed in: mahara
     Assignee: (unassigned) => Robert Lyon (robertl-9)

** Changed in: mahara
   Importance: Undecided => High

** Changed in: mahara
       Status: New => In Progress

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1787493

Title:
  Unable to have both "" and "0" as options in a select form and have ""
  the selected one

Status in Mahara:
  In Progress

Bug description:
  This is due to the function pieform_element_select_render_options()
  not checking on type

  the line
     $stringvalue = !is_array($values) && $key == $values;

  needs to be
     $stringvalue = !is_array($values) && $key === $values;

  To test create a select field with options like this:

  'options' => array("" => get_string('nocategoryselected', 'mahara')) +
  array_combine(range(100, 0), range(100, 0)),

   and have

  'defaultvalue' = '',

  
  Expected:  we should have the nocategoryselected option displayed
  Currently: we have the option "0" selected

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1787493/+subscriptions


Follow ups