You are here

function command_buttons_entity_edit_form in Command Buttons 7

Basic edit form for the button entity.

The entity being edited should be stored in $form_state['entity'] when this form is built.

2 string references to 'command_buttons_entity_edit_form'
command_buttons_entities_add_page in ./command_buttons.admin.inc
Page callback to add a new pane entity.
command_buttons_entity_edit_page in ./command_buttons.admin.inc
Page callback to view a entity.

File

./command_buttons.module, line 516

Code

function command_buttons_entity_edit_form($form, &$form_state) {
  $entity = $form_state['entity'];

  // Map these properties for entity translations.
  $form['#entity_type'] = array(
    '#type' => 'value',
    '#value' => $entity->bundle,
  );
  $form_state['command_button'] = $form_state['entity'];
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $entity->title,
    '#weight' => -10,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#default_value' => $entity->name,
    '#maxlength' => 21,
    '#machine_name' => array(
      'source' => array(
        'title',
      ),
      'exists' => 'command_buttons_machine_name_exists',
    ),
  );
  $form['language'] = array(
    '#type' => 'value',
    '#value' => $entity->language,
  );
  $language = NULL;
  if (function_exists('entity_language')) {

    // entity_language() was added in Drupal 7.15.
    $language = entity_language('command_button', $entity);
  }
  field_attach_form('command_button', $entity, $form, $form_state, $language);
  if (!empty($form_state['add submit'])) {
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
    );
  }
  return $form;
}