You are here

function commerce_coupon_form in Commerce Coupon 7.2

Same name and namespace in other branches
  1. 7 includes/commerce_coupon_ui.forms.inc \commerce_coupon_form()

Form callback: coupon add/edit form.

1 string reference to 'commerce_coupon_form'
commerce_coupon_coupon_form_wrapper in ./commerce_coupon.module
Page wrapper: coupon add/edit form.

File

includes/commerce_coupon.admin.inc, line 112
Administrative forms and callbacks for Commerce Coupon.

Code

function commerce_coupon_form($form, &$form_state, $coupon) {

  // Ensure this include file is loaded when the form is rebuilt from the cache.
  $form_state['build_info']['files']['form'] = drupal_get_path('module', 'commerce_coupon') . '/includes/commerce_coupon.admin.inc';
  $form_state['commerce_coupon'] = $coupon;
  commerce_coupon_attach_coupon_entity_form($form, $form_state, $coupon, TRUE);

  // Add responsive disabling of code element based on state of generate.
  $form['code']['#states'] = array(
    'disabled' => array(
      ':input[name="generate"]' => array(
        'checked' => TRUE,
      ),
    ),
  );
  $form['actions'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'form-actions',
      ),
    ),
    '#weight' => 400,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save coupon'),
    '#weight' => 40,
  );
  $form['#original'] = $coupon;
  return $form;
}