You are here

function photos_access_privacy_form_ajax in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 photos_access/photos_access.module \photos_access_privacy_form_ajax()
  2. 6.0.x photos_access/photos_access.module \photos_access_privacy_form_ajax()

Update privacy form when radio selection changes.

1 string reference to 'photos_access_privacy_form_ajax'
photos_access_form_node_form_alter in photos_access/photos_access.module
Implements hook_form_BASE_FORM_ID_alter() for form_node.

File

photos_access/photos_access.module, line 176
Implementation of photos_access.module.

Code

function photos_access_privacy_form_ajax(&$form, FormStateInterface $form_state) {
  $privacy = $form_state
    ->getValue('privacy');
  $response = new AjaxResponse();
  $response
    ->addCommand(new CssCommand('#photos_access_viewuser', [
    'display' => 'none',
  ]));
  $response
    ->addCommand(new CssCommand('#photos_access_remove', [
    'display' => 'none',
  ]));
  $response
    ->addCommand(new CssCommand('#photos_access_password', [
    'display' => 'none',
  ]));
  if ($privacy['viewid'] == 2) {

    // Users.
    $response
      ->addCommand(new CssCommand('#photos_access_viewuser', [
      'display' => 'block',
    ]));
    $response
      ->addCommand(new CssCommand('#photos_access_remove', [
      'display' => 'block',
    ]));
  }
  elseif ($privacy['viewid'] == 3) {

    // Password.
    $response
      ->addCommand(new CssCommand('#photos_access_password', [
      'display' => 'block',
    ]));
  }
  return $response;
}