1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Minor issue in custom_field_edit

Discussion in 'Resolved Bug Reports' started by sonnb, Nov 21, 2014.

  1. sonnb

    sonnb Well-Known Member

    If we have a custom field (in XF, RM or others which use custom_field_edit) type "Drop down selection". In case this field is not required and in "Possible Choices:" have a value equal 0, then on rendering, XF will choose the choice has value 0 instead of blank choice.

    Possible solution: Check if this field has a value in xen:selected
    Code:
    <option value="{$choice}" {xen:selected '{$field.hasValue} &&{$field.field_value} == {$choice}'}>{xen:raw $text}</option>
    Instead of:
    Code:
    <option value="{$choice}" {xen:selected '{$field.field_value} == {$choice}'}>{xen:raw $text}</option>
     
    trigatch4 likes this.
  2. Mike

    Mike XenForo Developer Staff Member

    I think a better fix is actually to use ===, as a field choice with a value of 0 could be selected instead of the user's choice if their choice is not a number (due to PHP's type coercion).
     
  3. sonnb

    sonnb Well-Known Member

    Yes. It is also a solution. The reason why I used hasValue check is just to be sure it has a value.
     

Share This Page