1

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:

<form ...>
    ... charge specific default stuff ...

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

    {% 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 ...
</form>
2
  • 2
    When you google a problem and find your own un-answered question from 8 months ago... Commented Apr 17, 2018 at 15:29
  • 1
    It's like a sad time machine which I have visited a few times to many.
    – Vin
    Commented May 13, 2018 at 1:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.