You are here

function eck__remove_extra_field_form_submit in Entity Construction Kit (ECK) 7.3

Callback to remove a property field from a bundle's field management form.

The property will no longer show on the entity's creation and edit forms.

File

./eck.bundle.inc, line 850

Code

function eck__remove_extra_field_form_submit($form, &$form_state) {
  if ($form_state['values']['confirm']) {
    $property_name = $form['#property_name'];
    $entity_type = $form['#entity_type'];
    $bundle = bundle_load($entity_type, $form['#bundle']->name);
    if (!empty($bundle->config['extra_fields'][$property_name]['form'])) {
      $config = $bundle->config;

      // Unset the extra field form settings for this property to no longer
      // manage it.
      unset($config['extra_fields'][$property_name]['form']);
      $bundle->config = $config;

      // Save the bundle.
      $bundle
        ->save();
      Bundle::loadAll(NULL, TRUE);
    }
  }
  $form_state['redirect'] = 'admin/structure/entity-type/' . $entity_type . '/' . $bundle->name . '/fields';
}