Home Forums Bug Reports Selects with values of 0 cannot default to null


Selects with values of 0 cannot default to null

  • If I build up a select and have an option that has a value of 0, it becomes the default selected value.

    If I mark allow null, I cannot get the select to default to –select–. I could change my starting value to 1 to get around this, but I have built up a number of fields with sequential values for conditional fields. If I change my values the conditionals are all messed up.

  • Hi @dachusa

    Thanks for the bug report. Just to clarify, the issue is if you create a select field with the choices 0 and 1, and also check the options for ‘allow null’, the value 0 is selected on new posts?


  • Correct.

    0 : First Option
    1 : Second Option

    Default null: selected

    Select box has:

    First Option (Selected)
    Second Option

  • This reply has been marked as private.
  • Hi @dachusa

    Thanks mate. I’ll look intoit.


  • That answer could help me too 🙂

  • Okay, I would suggest the following change :

    line 136, file /core/fields/select.php

    $selected = in_array(strval($key), array_map("strval", $field['value']) ) ? 'selected="selected"' : '';

    in order to solve this problem

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Selects with values of 0 cannot default to null’ is closed to new replies.