public function EntityLegalDocumentForm::form in Entity Legal 8
Same name and namespace in other branches
- 8.2 src/Form/EntityLegalDocumentForm.php \Drupal\entity_legal\Form\EntityLegalDocumentForm::form()
- 4.0.x src/Form/EntityLegalDocumentForm.php \Drupal\entity_legal\Form\EntityLegalDocumentForm::form()
- 3.0.x src/Form/EntityLegalDocumentForm.php \Drupal\entity_legal\Form\EntityLegalDocumentForm::form()
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ EntityLegalDocumentForm.php, line 40 - Contains \Drupal\entity_legal\Form\EntityLegalDocumentForm.
Class
- EntityLegalDocumentForm
- Entity Legal Document create and edit form handler.
Namespace
Drupal\entity_legal\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$legal_document = $this->entity;
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $legal_document
->label(),
'#description' => $this
->t('Administrative label for this legal document'),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $legal_document
->id(),
'#machine_name' => array(
'exists' => array(
$this,
'exists',
),
),
'#disabled' => !$legal_document
->isNew(),
);
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 27,
'#tree' => TRUE,
);
$form['new_users'] = array(
'#title' => t('New users'),
'#description' => t('Visit the !permissions page to ensure that users can view the document.', array(
'!permissions' => t('permissions'),
)),
'#type' => 'details',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
);
$form['new_users']['new_user_requirement'] = array(
'#title' => t('Require new users to accept this agreement on signup'),
'#type' => 'checkbox',
'#default_value' => $legal_document
->getNewUserRequirement(),
'#group' => 'new_users',
'#weight' => 0,
);
$new_user_plugins = array(
'' => t(' - Select a plugin -'),
) + \Drupal::service('plugin.manager.entity_legal.acceptance_method')
->getNewUserPluginOptions();
$form['new_users']['new_user_plugin_name'] = array(
'#title' => t('Present to user as'),
'#type' => 'select',
'#options' => $new_user_plugins,
'#default_value' => $legal_document
->getNewUserPluginName(),
'#states' => array(
'visible' => array(
':input[name="new_user_requirement"]' => array(
'checked' => TRUE,
),
),
),
'#group' => 'new_users',
'#weight' => 1,
);
$form['existing_users'] = array(
'#title' => t('Existing users'),
'#description' => t('Visit the !permissions page to configure which existing users these settings apply to.', array(
'!permissions' => t('permissions'),
)),
'#type' => 'details',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
);
$form['existing_users']['existing_user_requirement'] = array(
'#title' => t('Require existing users to accept this agreement'),
'#type' => 'checkbox',
'#default_value' => $legal_document
->getExistingUserRequirement(),
'#group' => 'existing_users',
'#weight' => 0,
);
$existing_user_plugins = array(
'' => t(' - Select a plugin -'),
) + \Drupal::service('plugin.manager.entity_legal.acceptance_method')
->getExistingUserPluginOptions();
$form['existing_users']['existing_user_plugin_name'] = array(
'#title' => t('Present to user as'),
'#type' => 'select',
'#options' => $existing_user_plugins,
'#default_value' => $legal_document
->getExistingUserPluginName(),
'#states' => array(
'visible' => array(
':input[name="existing_user_requirement"]' => array(
'checked' => TRUE,
),
),
),
'#group' => 'existing_users',
'#weight' => 1,
);
return $form;
}