Thanks for providing this library :)
There seams to be a type mismatch if you define numeric values for your choice values.
PHP transfers them into int but in the values from get_option are always strings.
Example Configuration:
'sample-page' => array(
'page_title' => __('Sample Page', 'sample-domain'),
'sections' => array(
'sample-section' => array(
'title' => __('Section One', 'sample-domain'),
'fields' => array(
'select' => array(
'title' => __('Select', 'sample-domain'),
'type' => 'select',
'value' => 'option-two',
'choices' => array(
'0' => __('Nothing selected', 'sample-domain'),
'1' => __('Not working', 'sample-domain'),
'x' => __('Working', 'sample-domain'),
),
),
)
)
),
),
);
Try to select the "Not working" choice.
PHP Array:
var_dump(array(
'0' => __('Nothing selected', 'sample-domain'),
'1' => __('Not working', 'sample-domain'),
'x' => __('Working', 'sample-domain'),
));
array(3) {
--
| [0]=>
| string(16) "Nothing selected"
| [1]=>
| string(11) "Not working"
| ["x"]=>
| string(7) "Working"
| }
get_option
var_dump(get_option('sample-page', array() ));
array(1) {
--
| ["select"]=>
| string(1) "1"
| }
My use case is to save have a dropdown for all categories, I would like to save just the id of the selected category, but at the moment I have to add a string prefix to make it work
Thanks for providing this library :)
There seams to be a type mismatch if you define numeric values for your choice values.
PHP transfers them into int but in the values from
get_optionare always strings.Example Configuration:
Try to select the "Not working" choice.
PHP Array:
get_option
var_dump(get_option('sample-page', array() ));My use case is to save have a dropdown for all categories, I would like to save just the id of the selected category, but at the moment I have to add a string prefix to make it work