Support Forum
Hi - my Select Custom Fields don't seem to show the saved the selection when you return to edit the page.
When editing a page I can make a selection and then click "Update" and the selection shows correctly in the front end. However, when I go back to edit the page later, the field in the select option just shows whatever is at the top of the select options rather than what was saved previously.
This means that if I make an edit to the page I also have to remember to re-select the correct field from the Select Custom Field as well as making whatever other edit I was there for.
Hi Harry,
Can you please share the code that creates the custom fields? I will check it on my end.
Hi Long - many thanks.
In fact, it does noes not overwrite with the default if you update the page but whatever is at the top of the select list is what shows in the field - even if you have selected something further down the list and saved previously. This means if you go to edit the page, you can't be sure the correct value has been selected from the Select field or not.
These are just text fields created using MB AIO so I'm not sure what code I can send you? Please let me know and I'll send it over.
Hi Harry,
You can generate the code by clicking on the button Get PHP Code in the Builder https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code
Hi Long - so here's the php for the select fields (personal names removed). As I said, the problem is that when you go back into the page to edit, the field does not show what was saved previously even though the correct information shows on the front end.
[
'name' => __( 'Host', 'your-text-domain' ),
'id' => $prefix . 'event_host',
'type' => 'select',
'options' => [
'TBC' => __( 'TBC', 'your-text-domain' ),
'Long Event - Several Hosts' => __( 'Long Event - Several Hosts', 'your-text-domain' ),
'XXX1' => __( 'XXX1', 'your-text-domain' ),
'XXX2' => __( 'XXX2', 'your-text-domain' ),
'XXX3' => __( 'XXX3', 'your-text-domain' ),
'XXX4' => __( 'XXX4', 'your-text-domain' ),
'XXX5' => __( 'XXX5', 'your-text-domain' ),
'XXX6' => __( 'XXX6', 'your-text-domain' ),
'XXX7' => __( 'XXX7', 'your-text-domain' ),
'XXX8' => __( 'XXX8', 'your-text-domain' ),
],
'required' => true,
],
Hi Harry,
There is nothing wrong with your code. It might come from another issue. Please follow the step Debugging Information to troubleshoot the issue https://support.metabox.io/topic/how-to-create-a-new-topic/
If it does not work, please share your site credentials via this form https://metabox.io/contact/. I will help you to check it.
Hi Harry,
I've received your site info in the ticket system and got the issue.
The choices of the select field in the Builder should be value: Label
and the value should not have &
character. You can use the space instead of it. Please re-check the field Event Host
and confirm it works.
That's great - many thanks Long. So just to check, if the select choices should be: "Bob Smith", "Mary Smith" and "Bob and Mary Smith", it would be entered in the builder as:
Bob Smith: Bob Smith
Mary Smith: Mary Smith
Bob and Mary Smith: Bob and Mary Smith
Thanks,
Harry
And just checking this would be ok also?
Bob Smith: Bob Smith
Mary Smith: Mary Smith
Bob and Mary Smith: Bob & Mary Smith
Yes, it would be ok. Just remove &
character from the value.
Bob Smith: Bob Smith
Mary Smith: Mary Smith
Bob and Mary Smith: Bob & Mary Smith