user561
(Marc)
1
I am trying to add an HTML element to each radio button, just after each tag. So where a radio button renders as
<li class='gchoice_10_5_0'>
<input name='input_5' type='radio' value='Item 1|10' id='choice_10_5_0' tabindex='1' />
<label for='choice_10_5_0' id='label_10_5_0'>First Choice</label>
</li>
I am trying to generate
<li class='gchoice_10_5_0'>
<input name='input_5' type='radio' value='Item 1|10' id='choice_10_5_0' tabindex='1' />
<label for='choice_10_5_0' id='label_10_5_0'>First Choice</label>
<div>New html here</div>
</li>
Any help would be appreciated.
user561
(Marc)
2
So I was able to modify the form output by using the gform_field_choice_markup_pre_render
filter as described in the [Gravity Forms documentation]
(gform_field_choice_markup_pre_render - Gravity Forms Documentation)
Here’s my code:
add_filter( 'gform_field_choice_markup_pre_render_4', function ( $choice_markup, $choice, $field, $value ) {
if ( $field->get_input_type() == 'radio' && rgar( $choice, 'text' ) == 'Option 1' ) {
$description = '<div>New html here</div>';
return str_replace( "</label>", "</label>$description", $choice_markup );
}
return $choice_markup;
}, 10, 4 );