function photos_form_alter in Album Photos 6.0.x
Same name and namespace in other branches
- 8.5 photos.module \photos_form_alter()
- 8.4 photos.module \photos_form_alter()
- 6.2 photos.module \photos_form_alter()
- 7.3 photos.module \photos_form_alter()
Implements hook_form_alter().
File
- ./
photos.module, line 847 - Implementation of photos.module.
Code
function photos_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
// Photos node form.
if ($form_id == 'node_photos_form') {
foreach (array_keys($form['actions']) as $action) {
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
$form['actions'][$action]['#submit'][] = 'photos_form_redirect';
}
}
}
// Photos image entity form.
if ($form_id == 'photos_image_add_form') {
$node = \Drupal::routeMatch()
->getParameter('node');
if ($node && !is_numeric($node)) {
if (isset($form['album_id'])) {
$form['album_id']['widget'][0]['target_id']['#default_value'] = $node;
}
}
}
}