Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 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:

Description

Hi,

While I working with multiselect dropdown box, I realized [selected]http://codex.wordpress.org/Function_Reference/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.

selected('1',array('1','3'));

Change History (1)

#1 @helen
10 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 10 years ago by helen (previous) (diff)
Note: See TracTickets for help on using tickets.