I've never seen this problem. That default value should work. I would say try making the key a string and set #default_value
as a string. The #options
array may be being passed through array_merge
somewhere, thus rekeying integer keys. If keys are strings then that shouldn't happen.
Currently, your array looks like this:
$options = array(
0 => '0',
500 => '500',
1000 => '1000',
);
But passing that array through array_merge
can reorganize those integer keys to be in sequential order:
$options = array(
0 => '0',
1 => '500',
2 => '1000',
);
If that happens then the 500
key simply doesn't exist. This is because array_merge
does not like to preserve integer keys, but you can use strings to prevent it.
So, I think your array should look more like this:
$options = array(
'0' => '0',
'500' => '500',
'1000' => '1000',
);
Then you can set your #default_value
:
$form['price']['min']['#default_value'] = '500';
Otherwise, is there anywhere else where the default_value
may be being overridden?