public function ActivityTypeForm::form in CRM Core 8
Same name and namespace in other branches
- 8.3 modules/crm_core_activity/src/Form/ActivityTypeForm.php \Drupal\crm_core_activity\Form\ActivityTypeForm::form()
- 8.2 modules/crm_core_activity/src/Form/ActivityTypeForm.php \Drupal\crm_core_activity\Form\ActivityTypeForm::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
- modules/
crm_core_activity/ src/ Form/ ActivityTypeForm.php, line 21
Class
- ActivityTypeForm
- Class ActivityTypeForm.
Namespace
Drupal\crm_core_activity\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/* @var \Drupal\crm_core_activity\Entity\ActivityType $type */
$type = $this->entity;
$form['name'] = [
'#title' => $this
->t('Name'),
'#type' => 'textfield',
'#default_value' => $type->name,
'#description' => $this
->t('The human-readable name of this activity type. It is recommended that this name begin with a capital letter and contain only letters, numbers, and spaces. This name must be unique.'),
'#required' => TRUE,
'#size' => 32,
];
$form['type'] = [
'#type' => 'machine_name',
'#default_value' => $type
->id(),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
// '#disabled' => $type->isLocked(),
'#machine_name' => [
'exists' => 'Drupal\\crm_core_activity\\Entity\\ActivityType::load',
'source' => [
'name',
],
],
'#description' => $this
->t('A unique machine-readable name for this activity type. It must only contain lowercase letters, numbers, and underscores.'),
];
$form['description'] = [
'#title' => $this
->t('Description'),
'#type' => 'textarea',
'#default_value' => $type->description,
'#description' => $this
->t('Describe this activity type.'),
];
// Primary fields section.
$form['activity_string_container'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Display settings'),
];
$form['activity_string_container']['activity_string'] = [
'#type' => 'textfield',
'#title' => $this
->t('Activity string'),
'#description' => $this
->t('Enter text describing the relationship between the contact and this activity. For example: Someone Somewhere registered for this activity.'),
'#default_value' => empty($type->activity_string) ? '' : $type->activity_string,
];
return $form;
}