[wp-trac] [WordPress Trac] #41857: Walker_PageDropdown doesn't set correct selected value when using value_field
WordPress Trac
noreply at wordpress.org
Wed Jul 22 16:55:25 UTC 2020
#41857: Walker_PageDropdown doesn't set correct selected value when using
value_field
-------------------------------+------------------------------
Reporter: it4life | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 4.8.1
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------------+------------------------------
Comment (by soupia18):
I arrived here because of this issue, as the wp_dropdown_pages cannot set
selected when value_field is other than the ID.
After reading the discussion above, about the possibility of using fields
with non-unique values, then there are 2 options here:
Either, the value_field makes no real sense to exist as an option, or
since it's there, then it should give the freedom to the developer to
decide how to use it: I mean with what field as default value. In that
case something like below would do the job:
{{{
if ( $page->{$args['value_field']} == $args['selected'] ) {
$output .= ' selected="selected"';
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41857#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list