function private_content_form_node_type_form_alter in Private content 8.2
Implements hook_form_FORM_ID_alter().
File
- ./
private_content.module, line 168 - A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.
Code
function private_content_form_node_type_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\node\NodeTypeInterface $type */
$type = $form_state
->getFormObject()
->getEntity();
$form['private_content'] = [
'#type' => 'details',
'#title' => t('Privacy settings'),
'#collapsible' => TRUE,
'#group' => 'additional_settings',
'#weight' => 20,
'#attached' => [
'library' => [
'private_content/nodetype',
],
],
];
$form['private_content']['private'] = array(
'#type' => 'radios',
'#title' => t('Privacy'),
'#description' => t('Privacy settings for nodes of this content type. Changing this value will update all existing nodes and rebuild access permissions.'),
'#options' => array(
PRIVATE_DISABLED => t('Disabled (always public)'),
PRIVATE_ALLOWED => t('Enabled (public by default)'),
PRIVATE_AUTOMATIC => t('Enabled (private by default)'),
PRIVATE_ALWAYS => t('Hidden (always private)'),
),
'#default_value' => $type
->getThirdPartySetting('private_content', 'private', PRIVATE_ALLOWED),
);
$form['#entity_builders'][] = 'private_content_form_node_type_form_builder';
}