You are here

function farm_entity_form_alter in farmOS 2.x

Implements hook_form_alter().

Hides the revision control from the user,

See also

farm_entity_entity_presave()

File

modules/core/entity/farm_entity.module, line 156
Contains farm_entity.module.

Code

function farm_entity_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Only alter content entity forms.
  $form_object = $form_state
    ->getFormObject();
  if (!$form_object instanceof ContentEntityFormInterface) {
    return;
  }

  // Only apply to farm controlled entities.
  $entity = $form_object
    ->getEntity();
  $entity_types = [
    'asset',
    'log',
    'plan',
    'quantity',
  ];
  if (!in_array($entity
    ->getEntityTypeId(), $entity_types)) {
    return;
  }

  // Disable access to the revision checkbox.
  $form['revision']['#access'] = FALSE;
}