Answers.Body: <p>My current workaround: Get the select field directly and set its options to the select field options: </p>
  
  <p><code>{% set donationRecurrenceOptions = craft.fields.getFieldByHandle('donationRecurrence').settings‌​.options %}</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-04T22:36:50.943Z
Answers.LastActivityDate: 2017-01-04T22:36:50.943Z
Answers.UserDisplayName: tofirius
Body: <p>I have a custom donation form that I'm using that includes some custom Craft fields. Two of those fields are dropdowns which I populated with options from within my Craft admin panel.</p>
  
  <p>Since this is a custom form, it must use Stripe.js, so I have the following lines in my template per the <a href="https://squarebit.co.uk/software/craft/charge/usage/quickstart/using-stripe-js" rel="nofollow noreferrer">tutorial on the SquareBit</a> site:</p>
  
  <pre><code>{% includeJsResource('charge/js/stripe_v2.min.js') %}
  {% includeJsResource('charge/js/jquery.charge.js') %}
  {% includejs %}
      $(this).charge();
  {% endincludejs %}
  </code></pre>
  
  <p>Here are my Payment options that are set inside the <code>&lt;form&gt;</code> declaration:</p>
  
  <pre><code>{% set chargePaymentOptions = { 'allowDynamic' : true, 'planCurrency': 'usd', } %}
  
  {{ craft.charge.setPaymentOptions(chargePaymentOptions) }}
  </code></pre>
  
  <p>I borrowed some code from the Charge plugin examples for initializing the select fields like so:</p>
  
  <pre><code>{{ forms.selectField({
       label: 'Donation Recurrence',
       name: 'donationRecurrence',
       id: 'donationRecurrence',
       options: (charge is defined ? charge.donationRecurrence.options),
       value: (charge is defined ? charge.donationRecurrence),
       errors: (charge is defined ? charge.getErrors('donationRecurrence'))
  }) }}
  
  {{ forms.selectField({
       label: 'Would you like to donate to a specific cause?',
       name: 'donationDesignation',
       id: 'donationDesignation',
       options: (charge is defined ? charge.donationDesignation.options),
       value: (charge is defined ? charge.donationDesignation),
       errors: (charge is defined ? charge.getErrors('donationDesignation'))
  }) }}
  </code></pre>
  
  <p>As you can see, the select fields get their options from the aforementioned pre-populated custom Craft fields. Those options do <em>not</em> show up on <em>first</em> page load, but if the form is subsequently submitted and comes back with errors, then the select field options appear.</p>
  
  <p>I figured out that on the first page load, doing a <code>dump(charge)</code> shows that the <code>charge</code> object does not exist until the page has been reloaded after the form was submitted.</p>
  
  <p>Thanks for any help.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-04T19:26:58.430Z
Comments.Text: My current workaround, get the field directly and set this to the select field options:
  `{% set donationRecurrenceOptions = craft.fields.getFieldByHandle('donationRecurrence').settings.options %}`
Comments.UserDisplayName: tofirius
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-04T22:06:59.460Z
Comments.Text: Would you mind adding your workaround as an answer, @tofirius?
Comments.UserDisplayName: Brad Bell
Tags: <plugins><plugin-charge>
Title: Charge object not available on first page load
ThreadText: # Charge object not available on first page load
  
  (Asked by: username_0 on 2017-01-03)
  
  I have a custom donation form that I'm using that includes some custom Craft fields. Two of those fields are dropdowns which I populated with options from within my Craft admin panel.
  
  Since this is a custom form, it must use Stripe.js, so I have the following lines in my template per the [tutorial on the SquareBit](https://squarebit.co.uk/software/craft/charge/usage/quickstart/using-stripe-js) site:
  
  ```
  {% includeJsResource('charge/js/stripe_v2.min.js') %}
  {% includeJsResource('charge/js/jquery.charge.js') %}
  {% includejs %}
      $(this).charge();
  {% endincludejs %}
  
  ```
  
  Here are my Payment options that are set inside the `<form>` declaration:
  
  ```
  {% set chargePaymentOptions = { 'allowDynamic' : true, 'planCurrency': 'usd', } %}
  
  {{ craft.charge.setPaymentOptions(chargePaymentOptions) }}
  
  ```
  
  I borrowed some code from the Charge plugin examples for initializing the select fields like so:
  
  ```
  {{ forms.selectField({
       label: 'Donation Recurrence',
       name: 'donationRecurrence',
       id: 'donationRecurrence',
       options: (charge is defined ? charge.donationRecurrence.options),
       value: (charge is defined ? charge.donationRecurrence),
       errors: (charge is defined ? charge.getErrors('donationRecurrence'))
  }) }}
  
  {{ forms.selectField({
       label: 'Would you like to donate to a specific cause?',
       name: 'donationDesignation',
       id: 'donationDesignation',
       options: (charge is defined ? charge.donationDesignation.options),
       value: (charge is defined ? charge.donationDesignation),
       errors: (charge is defined ? charge.getErrors('donationDesignation'))
  }) }}
  
  ```
  
  As you can see, the select fields get their options from the aforementioned pre-populated custom Craft fields. Those options do *not* show up on *first* page load, but if the form is subsequently submitted and comes back with errors, then the select field options appear.
  
  I figured out that on the first page load, doing a `dump(charge)` shows that the `charge` object does not exist until the page has been reloaded after the form was submitted.
  
  Thanks for any help.
  
  **Tags:** plugins, plugin-charge
  
  > **Comments:**
  > **username_0**: My current workaround, get the field directly and set this to the select field options: `{% set donationRecurrenceOptions = craft.fields.getFieldByHandle('donationRecurrence').settings.options %}`  
  > **username_1**: Would you mind adding your workaround as an answer, @username_0?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-01-04. Score: 1
  
  My current workaround: Get the select field directly and set its options to the select field options:
  
  `{% set donationRecurrenceOptions = craft.fields.getFieldByHandle('donationRecurrence').settings‌​.options %}`
  
  
  ---
  
  