You are here

function commerce_pricelist_list_form in Commerce Pricelist 7

Form function to create an commerce_pricelist_list entity.

The pattern is:

  • Set up the form for the data that is specific to your entity: the columns of your base table.
  • Call on the Field API to pull in the form elements for fields attached to the entity.
2 string references to 'commerce_pricelist_list_form'
commerce_pricelist_list_add in includes/commerce_pricelist.admin.inc
Provides a wrapper on the edit form to add a new entity.
commerce_pricelist_menu in ./commerce_pricelist.module
Implements hook_menu().

File

includes/commerce_pricelist.admin.inc, line 79
Summary

Code

function commerce_pricelist_list_form($form, &$form_state, $entity) {
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#required' => TRUE,
    '#default_value' => $entity->title,
  );
  $form['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Weight'),
    '#required' => TRUE,
    '#default_value' => $entity->weight,
  );
  $form['active'] = array(
    '#type' => 'checkbox',
    '#title' => t('Active'),
    '#default_value' => $entity->status,
  );
  $form['entity'] = array(
    '#type' => 'value',
    '#value' => $entity,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 100,
  );

  // Check if this is an existing item, add delete button
  if ($entity->list_id) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#submit' => array(
        'commerce_pricelist_list_edit_delete',
      ),
      '#weight' => 200,
    );
  }
  return $form;
}