Hi
Looking to generate a PDF of form entries after submission, but I cannot display and print the HTML fields from the form.
Can this be done native? Can it be done with custom development?
Many thanks for help on either.
Asa
Hi
Looking to generate a PDF of form entries after submission, but I cannot display and print the HTML fields from the form.
Can this be done native? Can it be done with custom development?
Many thanks for help on either.
Asa
What are you using to generate the PDF currently? A plugin, or custom code, or have you not yet started?
HTML fields are display only, so they’re not saved in the entry. This can’t be changed.
I would recommend to reach the author of your PDF add-on for advice on how to proceed with HTML fields.
Thanks Samuel - good information. I have reached out to both Gravity Flow to get their take, and also GravityPDF to see if they can help?
This is more of a GravityPDF question than a Gravity Forms question. The answer is to edit the PDF template and insert the HTML there between the dynamic fields coming from the form input.
Thanks tugmariner.
This is extremely helpful. I have reached out to GravityPDF so hopefully can work it out with them.
Appreciate the steer for my conversation with them.
For those who might be reading after the fact and looking for a similar solution, there are two that will work very easily with Gravity Flow PDF generator (and likely other tools/situations).
add_filter( 'gravityflowpdf_content', 'sh_pdf_content_modify', 10, 4 );
function sh_pdf_content_modify( $body, $file_path, $entry, $step ) {
$form = GFAPI::get_form( $entry['form_id'] );
foreach( $form['fields'] as &$field ){
if ($field->type == 'html'){
$content = GFCommon::replace_variables( $field->content, $form, $entry, false, true, false, 'html' );
}
}
return $content.$body;
}
add_filter( 'gform_replace_merge_tags', 'replace_html_field_tag', 10, 7 );
function replace_html_field_tag( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
$custom_merge_tag = '{html_fields}';
if ( strpos( $text, $custom_merge_tag ) === false ) {
return $text;
}
$text = '';
foreach ( $form['fields'] as &$field ) {
if ( $field->type == 'html' ) {
$text .= GFCommon::get_field_input( $field, '', 0, $form['id'], $form ) . '<br/><br/><br/>';
break;
}
}
return $text;
}