PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

getting labels from gravity form

  1. Krystian
    Member

    Hi, I'm writing a code which returns on the screen entries from my GForm. It's easy. But a have got one problem. I cannot get all labels of my field e.g form has three fields: name, surname, email. I don't see the last one

    $columns = RGFormsModel::get_grid_columns(2, false);
    echo var_export(RGFormsModel::get_lead(47),true); // 47 is some id

    echo var_export($columns,true);

    How to get all labels in order to achieve something like this:
    fieldLabel | entry
    fieldLabel | entry
    fieldLabel | entry

    if this is not a proper place in the forum to such a question please move it somewhere else

    Posted 13 years ago on Wednesday October 6, 2010 | Permalink
  2. The get_grid_columns() function will return the fields that you have configured in your entry list page. If you don't have the email being displayed in the list, that is the reason it is not getting displayed by your code.
    If that is not the case, I will be happy to help you with a code snippet, but I need some more details on what you are trying to accomplish. Is this just for this form or you will want to apply it to any other form? From the code above it looks like you want to display only one entry. Is that the case, or do you want to display a list of all entries for a form?

    Posted 13 years ago on Wednesday October 6, 2010 | Permalink
  3. Krystian
    Member

    Hi, thanks for reply. From the beginning. I wrote a plugin which adds user after filling the form. Login is email. Then after login such a user I would like to print his entries.
    here is my code so far. This code prints all values but not all labels and I don't know why?
    So again I would like to return label/name of the field from form and value which was entered by the user. Now for example this code returns 90% of what I need -> all values but not all names :( I hope it's clear for you
    link http://mundus.amu.edu.pl/tosca/application/test-shortcut-op

    add_shortcode('display-info', 'pre_submission_handler');
    function pre_submission_handler(){
    
    	require_once(ABSPATH . WPINC . "/wp-db.php");
     	global $wpdb;
    	global $current_user;
    
    	get_currentuserinfo();
    
          	echo 'Username: ' . $current_user->user_login . "<br />";
    
     	$sql = "SELECT * FROM <code>wp_rg_lead_detail</code> WHERE lead_id = 47"; // lead_id will be automaticly from logged user
    
        	$result = $wpdb->get_results($sql);
    
    	$columns = RGFormsModel::get_grid_columns(2, false);
    
    	echo '<table border="1">';
    
    	foreach($result as $row)
    	{
    		echo '<tr>';
    
    		echo '<td>';
    
    		echo $columns[$row->field_number][label] . "<br />";
    
    		echo '</td>';
    
    		echo '<td>';
    
    		echo $row->value . "<br />";
    
    		echo '</td>';
    
    		echo '</tr>';
    
    	}
    
    	echo '</table>';
    
    	echo var_export(RGFormsModel::get_lead(47),true);
    	echo var_export($columns,true);
    
    }
    Posted 13 years ago on Wednesday October 6, 2010 | Permalink
  4. I think the best way to do this is to use Gravity Forms' entry detail functions. It will render a table similar to the one displayed on the entry detail page. You can then style the table however you like. Following is the code snippet you will need.

    if(!class_exists("GFEntryDetail"))
        require_once("entry_detail.php");
    
    if(!class_exists("RGFormsModel"))
        require_once("forms_model.php");
    
    if(!class_exists("GFCommon"))
        require_once("common.php");
    
    $form = RGFormsModel::get_form_meta(53);
    $entry = RGFormsModel::get_lead(386);
    GFEntryDetail::lead_detail_grid($form, $entry);

    If this does not work for you and you need more control over the markup, I would copy and paste the lead_detail_grid() function to your functions.php file and make the modifications to the markup that you need to make.
    Good luck!

    Posted 13 years ago on Friday October 8, 2010 | Permalink