Select Custom Fields not saving selection
- This topic has 9 replies, 2 voices, and was last updated 3 years, 10 months ago by
Long Nguyen.
-
AuthorPosts
-
May 17, 2021 at 5:31 PM #28228
harryb
ParticipantHi - 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.
May 17, 2021 at 9:09 PM #28233Long Nguyen
ModeratorHi Harry,
Can you please share the code that creates the custom fields? I will check it on my end.
May 17, 2021 at 9:32 PM #28236harryb
ParticipantHi 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.
May 17, 2021 at 10:27 PM #28239Long Nguyen
ModeratorHi 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
May 18, 2021 at 8:20 PM #28270harryb
ParticipantHi 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, ],
May 18, 2021 at 9:30 PM #28275Long Nguyen
ModeratorHi 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.
June 9, 2021 at 10:12 PM #28799Long Nguyen
ModeratorHi 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 fieldEvent Host
and confirm it works.June 9, 2021 at 10:39 PM #28802harryb
ParticipantThat'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 SmithThanks,
Harry
June 9, 2021 at 10:43 PM #28803harryb
ParticipantAnd just checking this would be ok also?
Bob Smith: Bob Smith
Mary Smith: Mary Smith
Bob and Mary Smith: Bob & Mary SmithJune 10, 2021 at 12:13 PM #28815Long Nguyen
ModeratorYes, 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
-
AuthorPosts
- You must be logged in to reply to this topic.