Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#28746 closed feature request (fixed)

Add class argument to add_settings_field()

Reported by: euthelup's profile euthelup Owned by:
Milestone: 4.2 Priority: normal
Severity: normal Version:
Component: Administration Keywords:
Focuses: administration, template Cc:

Description

Hello!

I frequently find myself against this issue: I would like to control with javascript an entire option field and play with it but there is no way on making it unique.

So I came here (for the first time) and kindly ask you if we can have class argument on add_settings_field() function which should be put on the field's <tr> tag?

Is not a tremendous work you could replicate the "label_for" functionality, instead of :

		echo '<tr>';
		if ( !empty($field['args']['label_for']) )
			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
		else
			echo '<th scope="row">' . $field['title'] . '</th>';

it should be :

		if ( !empty($field['args']['class']) )
			echo '<tr class="' . esc_attr( $field['args']['class'] ) . '">';
		else
			echo '<tr>';
		
		if ( !empty($field['args']['label_for']) )
			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
		else
			echo '<th scope="row">' . $field['title'] . '</th>';

I still dream of the day when I can change myself the table markup to divs and spans but i guess it will remain a dream(and maybe this is not the topic to disqus that).

P.S: my first ticket, sorry for anything i miss and take me slow.

Best Regards,
Andrei Lupu

Change History (3)

#1 @obenland
10 years ago

  • Version trunk deleted

Hm, couldn't you select the label and then look for the closest li element?

#2 @euthelup
10 years ago

I agree, this could work partially.

But the label is public, and one could be used more than once. The class is hidden for the end-user and can be individual for each field.

I think we should avoid create some complex jQuery searches when we can config a simple class.

#3 @wonderboymusic
9 years ago

  • Milestone changed from Awaiting Review to 4.2
  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.