The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

help to change radiobutton in a single field

Labels

This Discussion is public

Notifications

hi community

i am building this donation form for a client: https://retina.ch/spenden/spenden-neu/

in order to change color of selected yellow button, i need to change order of label input in radiobutton, with the function below it works, but this changes all radiobuttons, i would like to be able to change only the ones in field id 242

would anybody know how to achieve that?

nadia

 

// RADIOBUTTON REMOVE label

add_filter('frm_replace_shortcodes', 'frm_change_my_html', 10, 3);
function frm_change_my_html($html, $field, $args){
if ( in_array ( $field['type'], array( 'radio', 'checkbox' ) ) ) {
$temp_array = explode('/>', $html);
$new_html = '';
foreach ( $temp_array as $key => $piece ) {
// Get current for attribute
if ( ( $pos = strpos( $piece, 'field_' . $field['field_key'] . '-' ) ) !== FALSE ) {
$new_key = substr( $piece, $pos );
$key_parts = explode( '"', $new_key, 2);
$new_key = reset( $key_parts );
} else {
$new_html .= $piece;
continue;
}
// Move opening label tag
$label = '<label for="' . $new_key . '">';
$new_html .= str_replace( $label, '', $piece );
$new_html .= '/>' . $label;
}
$html = $new_html;
}
return $html;
}

Discussion closed.