Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#25329 closed feature request (invalid)

selected function is not supporting the multiselect dropdown

Reported by: gchokeen's profile gchokeen Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6.1
Component: General Keywords:
Focuses: Cc:



While I working with multiselect dropdown box, I realized [selected] function is not supporting the multi select value. For example if selected function is not compatible to handle the array values.

I think we need to use in_array in the function to resolve this trouble.


Change History (1)

#1 @helen
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Since selected() is comparing values, you should see if in_array() returns true. And since it can accept that the first value is just true or false, you can just use it as the first argument.

$value = '1';
selected( in_array( $value, array( '1', '3' ) ) );
Last edited 11 years ago by helen (previous) (diff)
Note: See TracTickets for help on using tickets.