You are here

function flexiform_form_submit in Flexiform 7

Form API submit callback for the type form.

1 string reference to 'flexiform_form_submit'
flexiform_form in ./flexiform.admin.inc
Generates the model type editing form.

File

./flexiform.admin.inc, line 699
Model type editing UI.

Code

function flexiform_form_submit(&$form, &$form_state) {
  $flexiform = entity_ui_form_submit_build_entity($form, $form_state);

  // Make sure access plugins don't get overridden.
  if (empty($flexiform->is_new)) {
    $db_flexiform = entity_load_unchanged('flexiform', $flexiform->id);
    $flexiform->access = $db_flexiform->access;

    // Set access logic.
    $flexiform->access['settings']['logic'] = $form_state['values']['logic'];
  }

  // Sort out tags.
  $flexiform->tags = drupal_explode_tags($form_state['values']['tags']);
  $base_entity_info = entity_get_info($flexiform->base_entity);
  if (empty($flexiform->entities)) {
    $flexiform->entities = array(
      'base_entity' => array(
        'label' => t('Base @entity_type', array(
          '@entity_type' => $base_entity_info['label'],
        )),
        'entity_type' => $flexiform->base_entity,
        'bundle' => $flexiform->base_entity_bundle,
        'create' => TRUE,
        'getter' => 'base_entity',
        'weight' => -10,
      ),
    );
  }
  if (empty($flexiform->elements)) {
    $flexiform->elements = array();
  }
  $flexiform
    ->save();
  if (empty($form_state['redirect'])) {
    if ($form_state['op'] == 'add') {
      $form_state['redirect'] = 'admin/structure/flexiforms/manage/' . $flexiform->form . '/form-fields';
    }
    else {
      $form_state['redirect'] = 'admin/structure/flexiforms';
    }
  }
  $form['#flexiform'] = $flexiform;
}