<p>We are using Charge and have two custom fields we want to populate when a charge is successful. One works and one doesn't.</p>

<p>We can get it to populate a "pageTitle" field which is pretty standard as a hidden field.</p>

<p>The other field's value needs to change based on the selected planChoice - this one doesn't save anything. The Charge works but the custom field remains blank. Any ideas how to get this to work?</p>

<p>Here's stripped down code:</p>

<pre><code>&lt;form ...&gt;
    ... charge specific default stuff ...

    &lt;input type="hidden" name="fields[pageTitle]" value="{{ entry.title | e }}"/&gt;&lt;!-- This is a custom field on the Charge, that does get saved --&gt;

    {% set options = {
        'planChoices' : {
            'two' : {
                'label' : "This is a standard Charge field #{entry.title}",
                'planAmount' : (ticketPrice * 2),
                'fields[ticketInfo]' : "This is a custom field on Charge that doesn't get saved #{entry.title}"
             },
             ...
         }
    } %}

    {{ craft.charge.setPaymentOptions(options) }}

    {{ forms.select({
        label:   'Plan Choice',
        name:    'planChoice',
        id:      'planChoice',
        options: options.planChoices,
        value:   (charge is defined ? charge.planChoice),
        errors:  (charge is defined ? charge.getErrors('planChoice'))
    }) }}

    ... other normal form bits ...
&lt;/form&gt;
</code></pre>

CC BY-SA 3.0
2018-04-17T15:29:38.587Z
When you google a problem and find your own un-answered question from 8 months ago...
Matt Wilcox
CC BY-SA 4.0
2018-05-13T01:49:07.693Z
It's like a sad time machine which I have visited a few times to many.
Vin
<plugin-charge>
Populating a Custom Field via a Plan Choice in Charge?
# Populating a Custom Field via a Plan Choice in Charge?

(Asked by: username_0 on 2017-08-16)

We are using Charge and have two custom fields we want to populate when a charge is successful. One works and one doesn't.
We can get it to populate a "pageTitle" field which is pretty standard as a hidden field.
The other field's value needs to change based on the selected planChoice - this one doesn't save anything. The Charge works but the custom field remains blank. Any ideas how to get this to work?
Here's stripped down code:

    ... charge specific default stuff ...

    

    {% set options = {
        'planChoices' : {
            'two' : {
                'label' : "This is a standard Charge field #{entry.title}",
                'planAmount' : (ticketPrice * 2),
                'fields[ticketInfo]' : "This is a custom field on Charge that doesn't get saved #{entry.title}"
             },
             ...
         }
    } %}

    {{ craft.charge.setPaymentOptions(options) }}

    {{ forms.select({
        label:   'Plan Choice',
        name:    'planChoice',
        id:      'planChoice',
        options: options.planChoices,
        value:   (charge is defined ? charge.planChoice),
        errors:  (charge is defined ? charge.getErrors('planChoice'))
    }) }}

    ... other normal form bits ...

**Tags:** plugin-charge

> **Comments:**
> **username_0**: When you google a problem and find your own un-answered question from 8 months ago...  
> **username_1**: It's like a sad time machine which I have visited a few times to many.  

---

## 0 answers

