function auto_entityqueue_form_alter in Auto Entityqueue 8
Implements hook_form_alter().
Adds an additional option allowing entities to be added upon creation.
File
- ./
auto_entityqueue.module, line 18 - Handles automatically adding entities to entityqueues.
Code
function auto_entityqueue_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (preg_match('/^entity_queue_(add|edit)_form$/', $form_id)) {
// Get entity settings from the queue.
$entity_settings = $form_state
->getFormObject()
->getEntity()
->getEntitySettings();
$form['entity_settings']['settings']['handler_settings']['auto_entityqueue'] = array(
'#title' => t('Auto Entityqueue'),
'#type' => 'fieldset',
);
// Add a checkbox setting for automatically adding entities.
$form['entity_settings']['settings']['handler_settings']['auto_entityqueue']['auto_add'] = array(
'#default_value' => isset($entity_settings['handler_settings']['auto_entityqueue']['auto_add']) ? $entity_settings['handler_settings']['auto_entityqueue']['auto_add'] : FALSE,
'#description' => t('New entities of selected types will be automatically added to the queue.'),
'#title' => t('Automatically add entities to queue'),
'#type' => 'checkbox',
);
// Add a checkbox setting for insert position.
$form['entity_settings']['settings']['handler_settings']['auto_entityqueue']['insert_front'] = array(
'#default_value' => isset($entity_settings['handler_settings']['auto_entityqueue']['insert_front']) ? $entity_settings['handler_settings']['auto_entityqueue']['insert_front'] : FALSE,
'#description' => t('By default items are added at the back of the queue. If checked, items will be added at the front of the queue.'),
'#title' => t('Insert entities at front of queue'),
'#states' => array(
'invisible' => array(
':input[name="entity_settings[handler_settings][auto_entityqueue][auto_add]"]' => array(
'checked' => FALSE,
),
),
),
'#type' => 'checkbox',
);
}
}