Including checked and unchecked checkbox items in Gravity PDF

I’ve been after a way to print both checked and unchecked boxes from a Gravity Forms form with checkboxes using a PDF generated by the free Gravity PDF license. With some great help from Joshua at Gravity Forms support, here’s what I came up with and thought it would be helpful for the community. This snippet is restricted to form 39.

add_filter( 'gfpdf_pdf_field_content', function( $value, $field, $entry, $form, $pdf_field ) {
	
	$form_id = rgar ( $form, 'id');

	if ( $form_id == '39' ) {
		
       	if ( $field->type == 'checkbox' ) {

    	   	remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );

       		$items = '<ul style="list-style:none;">';
 
       		foreach ( $field->inputs as $input ) {

				$input_value = rgar( $entry, $input['id'] );

				if ( $input_value ) {
					$items .= "<li><span style='font-size: 150%;'>☑︎</span> {$input['label']}</li>";
           		} else {
               		$items .= "<li><span style='font-size: 150%;'>☐</span> {$input['label']}</li>";
           		}
 
       		}

       		$items .= '</ul>';

       		return $items;
		}
    }
	
    return $value;
	
}, 10, 5 );
3 Likes

Thank you for sharing that!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.