You are here

function commerce_coupon_form in Commerce Coupon 7

Same name and namespace in other branches
  1. 7.2 includes/commerce_coupon.admin.inc \commerce_coupon_form()

Generates the commerce coupon editing form.

1 string reference to 'commerce_coupon_form'
commerce_coupon_ui_coupon_form_wrapper in ./commerce_coupon_ui.module
Form callback wrapper: create or edit a coupon.

File

includes/commerce_coupon_ui.forms.inc, line 11
Commerce Coupon editing UI.

Code

function commerce_coupon_form($form, &$form_state, $coupon, $op = 'edit') {

  // TODO: add a validation method to check, that the code is not a duplicate!
  // 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_ui.forms.inc';

  // Add the field related form elements.
  $form_state['commerce_coupon'] = $coupon;
  $form_state['op'] = $op;
  field_attach_form('commerce_coupon', $coupon, $form, $form_state);
  $form['is_active'] = array(
    '#title' => t('Active'),
    '#type' => 'checkbox',
    '#default_value' => $coupon->is_active,
    '#description' => t('Indicates if the coupon can be used or not.'),
    '#size' => 30,
    '#weight' => 40,
  );
  $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,
  );
  return $form;
}