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.

Programatically accessing decimal field values

  1. I'm struggling to word this in a way that makes sense, but here goes:

    I'm writing some code that loops through each entry and gathers the values stored in each field. This works perfectly for anything with a single value per field - inputs, dropdowns, etc. - but is showing some strange behavior on names, addresses, and other fields where the values are stored in multiple parts.

    For some reason, when I use RGFormsModel::get_field_value() on those items, only the values stored in numbers divisible by .5 are displayed. For instance, I have address data stored at 7.1, 7.2, 7.4, 7.4, 7.5, and 7.7. When I access the data, only the value stored at 7.5 comes up. I've tried several different methods of accessing the data, and the same thing happens each time.

    Here's the relevant code snippet:

    $leads = RGFormsModel::get_leads(1);
    	foreach($leads as $lead)
    	{
    		echo '<tr>';
    		foreach($field_ids as $field_id)
    		{
    			$value = get_field_value($field_id, $lead['id']);
    			if(!$value)
    			{
    				$field = RGFormsModel::get_field($form, $field_id);
    				$value_list = RGFormsModel::get_field_value($field);
    				$value = '';
    				foreach(array_keys($value_list) as $value_item) {
    					$value .= get_field_value($value_item, $lead['id']).' ';
    				}
    			}
    
    			echo '<td>'.$value.'</td>';
    		}
    		echo '</tr>';
    	}
    Posted 12 years ago on Wednesday May 18, 2011 | Permalink
  2. Since you already have the lead (and all the lead values), you might be doing more than you need to. Here is a snippet that might be helpful. In order to get the float valued IDs, I cast them as a string before retrieving those IDs from the lead.

    http://pastie.org/1923709

    Posted 12 years ago on Wednesday May 18, 2011 | Permalink
  3. Hm -- same result. Your solution looks right, but out of all the float valued IDs, I'm still only getting the one at 7.5.

    The plot thickens - I just checked the default Gravity Forms Entries page, and the same thing happens. The values are intact in the database, they just can't be accessed.

    Posted 12 years ago on Wednesday May 18, 2011 | Permalink
  4. Any chance you could send a login to your WP admin and FTP to david@rocketgenius.com? I'll take a look tomorrow morning for you.

    Posted 12 years ago on Thursday May 19, 2011 | Permalink
  5. It's all local at the moment, but if I can't solve it soon I'll put it online and send you the link. Thanks for your help!

    Posted 12 years ago on Thursday May 19, 2011 | Permalink