Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option group to select field ?? #1120

Closed
ravishakya opened this issue Sep 15, 2016 · 2 comments
Closed

Add option group to select field ?? #1120

ravishakya opened this issue Sep 15, 2016 · 2 comments
Assignees
Milestone

Comments

@ravishakya
Copy link

Issue description:

I want to add option group to select field. I want to display posts and pages in the select field. If i dont put optgroup then the user cannot distinguish between which is post and which is pages. Is it possible to add optgroup tag ??

eg output.

<select>
<optgroup label="Posts">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="Pages">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>

@aristath
Copy link
Contributor

I'm planning to refactor the select fields soon so I'm adding this one as a feature request...

@aristath aristath modified the milestone: 2.3.7 Sep 15, 2016
@aristath aristath self-assigned this Sep 16, 2016
@aristath aristath modified the milestones: 2.3.8, 2.3.7 Sep 17, 2016
@aristath aristath modified the milestones: 2.3.8, 2.4.0 Dec 10, 2016
@aristath aristath modified the milestones: 2.4.0, 3.0 Mar 28, 2017
@aristath
Copy link
Contributor

Implemented in 3.0 (develop branch).

Example:

Kirki::add_field( 'my_theme', array(
	'type'        => 'select',
	'settings'    => 'my_setting',
	'label'       => __( 'This is the label', 'my_textdomain' ),
	'section'     => 'my_section',
	'default'     => 'option-1',
	'priority'    => 10,
	'multiple'    => 3,
	'choices'     => array(
		'option-1' => esc_attr__( 'Option 1', 'my_textdomain' ),
		'option-2' => esc_attr__( 'Option 2', 'my_textdomain' ),
		'optgroup1' => array(
			esc_attr__( 'Optgroup 1', 'my_textdomain' ),
			array(
				'option-3' => esc_attr__( 'Option 3', 'my_textdomain' ),
				'option-4' => esc_attr__( 'Option 4', 'my_textdomain' ),
				'option-5' => esc_attr__( 'Option 5', 'my_textdomain' ),
			),
		),
		'optgroup2' => array(
			esc_attr__( 'Optgroup 2', 'my_textdomain' ),
			array(
				'option-6' => esc_attr__( 'Option 6', 'my_textdomain' ),
				'option-7' => esc_attr__( 'Option 7', 'my_textdomain' ),				
			),
		),
		'option-8' => esc_attr__( 'Option 8', 'my_textdomain' ),
	),
) );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants