WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms + Custom Post Types
[closed] How to get values from checkbox (7 posts)

  1. eagerbob
    Member
    Posted 1 year ago #

    Hello,
    I can't seem to get the values from a checkbox in my Gravity Form.
    I am using Advanced Custom Fields to make my custom fields.
    All other Gravity Form fields map correctly to my custom fields, except the checkbox. Tried all combinations, text only seems to give me the firts value.

    Am I missing something or is this something that is not supported?

    Thanks

    http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/

  2. dejliglama
    Member
    Posted 10 months ago #

    I have this issue as well for checkboxes.

    And for radio boxes no values are saved...

  3. Courtney Engle Robertson
    Member
    Posted 8 months ago #

    Pondering this issue myself as well

  4. cdodge
    Member
    Posted 7 months ago #

    Hello everyone,

    I have just spent a good 3 hours trying to solve this and I have found a solution that has worked perfectly for myself. I will try to explain as best I can and its not necessarily the best solution, but it works.

    You will need to use the following code for each checkbox field you have in order to fully populate all selected checkbox values -

    YOUR_FORM_ID = the ID of the Gravity Form You have created
    ACF_FIELDNAME = the exact Advanced Custom Fields Field Name of Your Checkbox Field Type.
    ACF_FIELD_KEY = The Field Key of your checkbox Field Type in Advanced Custom Fields. (To get the Field Key open up Custom Fields and go to "Screen Options" at the top of the screen and select "Show Field Key = Yes"

    Paste the following into functions.php

    add_action("gform_after_submission_YOUR_FORM_ID", "acf_post_submission", 10, 2);
    
    function acf_post_submission ($entry, $form)
    {
    $post_id = $entry["post_id"];
    $values = get_post_custom_values("ACF_FIELDNAME", $post_id);
    update_field("ACF_FIELD_KEY", $values, $post_id);
    }
  5. marujobhz
    Member
    Posted 3 months ago #

    hi, anyone can help me.
    i have an gravity form. and need to send some value to a php function that calc a price.
    im using this in confirmations:

    <form method='POST' id='gform_2' action='http://www....prices.php'>
        <input type='hidden' name='sacado' value='{Nome completo para certificado:1}'/>
        <input type='hidden' name='endereco1' value='{Endere├žo e Bairro:6}'/>
        <input type='hidden' name='endereco2' value='{Cidade:7}'/>
        <input type='hidden' name='categoria' value='{Categoria:12}'/>
        <input type='hidden' name='pontuacao_cna' value='14'>
    </form>
    <script type="text/javascript">
        jQuery("#gform_2").submit();
    </script>

    and in the price php i have this funcion (part of this):

    $valor = number_format(calcula_preco($d,$categoria,$pontuacao_cna),2,',','.');
    $categoria = 1;
    $nosso_numero = incrementa_numero($sacado,$email);
    function calcula_preco($d,$categoria,$pontuacao_cna){
    	$categoria = trim($categoria);
    	if(strtotime($d) <= strtotime('2014-04-01')){
    		$preco = '500';
    	}else{
    		$preco = '500';
    	}
    	if($categoria == 'Medicos Socios Quites'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '400';
    		}else{
    			$preco = '400';
    		}
    	}
    
    	if($categoria == 'Medicos Socios Nao Quites'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '500';
    		}else{
    			$preco = '500';
    		}
    	}
    
    	if($categoria == 'Nao Socios'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '500';
    		}else{
    			$preco = '500';
    		}
    	}
    
    if($categoria == 'Residentes'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '250';
    		}else{
    			$preco = '250';
    		}
    	}
    
    if($categoria == 'Outros'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '250';
    		}else{
    			$preco = '250';
    		}
    	}
    	$pontuacao_cna = trim($pontuacao_cna);
    	if($pontuacao_cna == 'CNA'){
    		$preco = $preco + 25;
    	}
    
    return $preco;
    }

    in form, if user check 'pontuacao cna' the function must plus 25 usd in price. but is does not works.
    any idea, anyone can help me?
    thanks!

  6. VFHwebdev
    Member
    Posted 2 months ago #

    Just adding my voice to the thread. I'm having the same issue with checkboxes. cdodge's fix worked for me, but what a pain in the but to do that for every checkbox on every form.

    Hoping they fix this in the next update.

  7. esmi
    Forum Moderator
    Posted 2 months ago #

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else's topic.

    I am now closing this 10 month old topic as it references an older version of WordPress.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags