I have a custom form field where the value could be zero for radio elements:
$yes_no_options = [ '1' => t('Yes'), '0' => t('No'), ]; $form['config_name'] = [ '#options' => $yes_no_options, '#default_value' => $config->get('config_name') ?: 1, ];
$config->get('config_name') is either equal to 0, or 1. This value gets passed to my .module file to be used in hook_node_access_records(), so 0 and 1 would be preferred.
I could do some converting in the .module file but I am curious if there is a worth while way to allow the 0 value when comparing?
Also wondering the pertinence of worrying about a default value comparison in the form field? If the default value can be set in the hook() maybe this isn't necessary and should just write
'#default_value' => $config->get('config_name'),?