• Resolved crlannen

    (@crlannen)


    In my custom template I needed to have a hyphen (-) as a separator between the degree/certification and the granting institution. On rhw doem rhwew EW 5 degree/granting institutions, and if the degree field is blank I didn’t want a hyphen appearing with no information in the PDF.

    {Degree/Certification:7}<?php
    $separator = $form_data['field'][7];
    // only print out hyphen if the certification field is completed
      if ($separator != "")
      {
      echo " - ";
    } ?> {Educational Institution/Professional Organization:8}

    The above is repeated for each of the additional degrees, but with the Degree/Certification field number changed.

    I hope this helps someone.

    https://wordpress.org/plugins/gravity-forms-pdf-extended/

Viewing 1 replies (of 1 total)
  • Plugin Author Jake Jackson

    (@blue-liquid-designs)

    Hi,

    When working with repetitive data like you mentioned we find it’s best to make an array with your field IDs and loop through it:

    <?php 
    
    $certificates = array(
        array(
            'degree'    => $form_data['field'][7],
            'education' => $form_data['field'][8],
        ),
    
        array(
            'degree'    => $form_data['field'][10],
            'education' => $form_data['field'][12],
        ),
    
        array(
            'degree'    => $form_data['field'][16],
            'education' => $form_data['field'][20],
        ),
    );
    
    foreach ( $certificates as $item ) {
        if( strlen( $item['degree'] ) > 0 && strlen( $item['education'] ) > 0 ) {
            echo $item['degree'] . ' – ' . $item['education'] .'<br>';
        }
    }

    Change the field IDs as needed and modify the conditional to suit.

Viewing 1 replies (of 1 total)
  • The topic ‘Sharing a conditional statement’ is closed to new replies.