Jump to content


issue with field_type dropdown

field_type dropdown

  • Please log in to reply
2 replies to this topic

#1 aramishvili

aramishvili

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 26 July 2017 - 03:21 PM

Hello, I'm new here and have stumbled on a problem when using field_type dropdown with an array that goes something like this

 

array('0'=>'zero', '1'=>'one'... etc.

 

The problem is that when the value is 0 the dropdown does not select it when editing.

 

How can I work around this issue? 

 

Changing the table in database to start from 1 is not an option.

 

dRzOKwB.png



#2 aramishvili

aramishvili

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 26 July 2017 - 04:11 PM

Solved this issue by modifying the function "get_dropdown_input" in "application/libraries/Grocery_CRUD.php".

 

On line 2405 I changed this:

$selected = !empty($value) && $value == $option_value ? "selected='selected'" : '';

to this:

$selected = !is_null($value) && $value == $option_value ? "selected='selected'" : '';

The issue was caused by the fact that empty() returns true on 0.



#3 goshikamahi

goshikamahi

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 24 June 2019 - 06:39 AM

Hi @aramishvili,

 

Thanks for help. you saved my time







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users