public function LingotekIntelligenceMetadataForm::buildForm in Lingotek Translation 3.3.x
Same name and namespace in other branches
- 8.2 src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 4.0.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.0.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.1.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.2.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.4.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.5.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.6.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.7.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
- 3.8.x src/Form/LingotekIntelligenceMetadataForm.php \Drupal\lingotek\Form\LingotekIntelligenceMetadataForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ LingotekIntelligenceMetadataForm.php, line 26
Class
- LingotekIntelligenceMetadataForm
- Helper class for creating the form for setting up the intelligence metadata.
Namespace
Drupal\lingotek\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$metadata = $this
->getIntelligenceMetadata($form_state);
$form['intelligence_metadata'] = [
'#type' => 'details',
'#title' => $this
->t('Lingotek Intelligence Metadata'),
'#tree' => TRUE,
];
$form['intelligence_metadata']['use_author'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Content\'s Author name and email to be tracked',
'#default_value' => $metadata
->getAuthorPermission(),
];
$form['intelligence_metadata']['use_author_email'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'checkbox',
'#title' => 'Enable the Content Author\'s email to be tracked',
'#default_value' => $metadata
->getAuthorEmailPermission(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_author]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_contact_email_for_author'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'checkbox',
'#title' => 'Use the Contact Email as the Author Default Email',
'#default_value' => $metadata
->getContactEmailForAuthorPermission(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_author]"]' => [
'checked' => TRUE,
],
':input[name="intelligence_metadata[use_contact_email]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['default_author_email'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Default Author Email'),
'#description' => $this
->t('Only used if the Author does not have an email address'),
'#default_value' => $metadata
->getDefaultAuthorEmail(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_author]"]' => [
'checked' => TRUE,
],
':input[name="intelligence_metadata[use_author_email]"]' => [
'checked' => TRUE,
],
':input[name="intelligence_metadata[use_contact_email_for_author]"]' => [
'checked' => FALSE,
],
],
],
];
$form['intelligence_metadata']['use_business_unit'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Business Unit to be tracked',
'#default_value' => $metadata
->getBusinessUnitPermission(),
];
$form['intelligence_metadata']['business_unit'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Business Unit'),
'#default_value' => $metadata
->getBusinessUnit(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_business_unit]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_business_division'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Business Division to be tracked',
'#default_value' => $metadata
->getBusinessDivisionPermission(),
];
$form['intelligence_metadata']['business_division'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Business Division'),
'#default_value' => $metadata
->getBusinessDivision(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_business_division]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_campaign_id'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Campaign ID to be tracked',
'#default_value' => $metadata
->getCampaignIdPermission(),
];
$form['intelligence_metadata']['campaign_id'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Campaign Id'),
'#default_value' => $metadata
->getCampaignId(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_campaign_id]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_campaign_rating'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Campaign Rating to be tracked',
'#default_value' => $metadata
->getCampaignRatingPermission(),
];
$form['intelligence_metadata']['campaign_rating'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'number',
'#title' => $this
->t('Campaign Rating'),
'#default_value' => $metadata
->getCampaignRating(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_campaign_rating]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_channel'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Channel to be tracked',
'#default_value' => $metadata
->getChannelPermission(),
];
$form['intelligence_metadata']['channel'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Channel'),
'#default_value' => $metadata
->getChannel(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_channel]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_contact_name'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Contact Name to be tracked',
'#default_value' => $metadata
->getContactNamePermission(),
];
$form['intelligence_metadata']['contact_name'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Contact Name'),
'#default_value' => $metadata
->getContactName(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_contact_name]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_contact_email'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Contact Email to be tracked',
'#default_value' => $metadata
->getContactEmailPermission(),
];
$form['intelligence_metadata']['contact_email'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Contact Email'),
'#default_value' => $metadata
->getContactEmail(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_contact_email]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_content_description'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Content Description to be tracked',
'#default_value' => $metadata
->getContentDescriptionPermission(),
];
$form['intelligence_metadata']['content_description'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Content Description'),
'#default_value' => $metadata
->getContentDescription(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_content_description]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_base_domain'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Base Domain to be tracked',
'#default_value' => $metadata
->getBaseDomainPermission(),
'#description' => 'This value will be pulled from the entities location and cannot be edited',
];
$form['intelligence_metadata']['use_reference_url'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Reference URL to be tracked',
'#default_value' => $metadata
->getReferenceUrlPermission(),
'#description' => 'This value will be pulled from the entities location and cannot be edited',
];
$form['intelligence_metadata']['use_external_style_id'] = [
'#type' => 'checkbox',
'#title' => 'Enable the External Style ID to be tracked',
'#default_value' => $metadata
->getExternalStyleIdPermission(),
];
$form['intelligence_metadata']['external_style_id'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('External Style Id'),
'#default_value' => $metadata
->getExternalStyleId(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_external_style_id]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_purchase_order'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Purchase Order to be tracked',
'#default_value' => $metadata
->getPurchaseOrderPermission(),
];
$form['intelligence_metadata']['purchase_order'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Purchase Order'),
'#default_value' => $metadata
->getPurchaseOrder(),
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_purchase_order]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['use_region'] = [
'#type' => 'checkbox',
'#title' => 'Enable the Region to be tracked',
'#default_value' => $metadata
->getRegionPermission(),
];
$form['intelligence_metadata']['region'] = [
'#attributes' => [
'class' => [
'indented',
],
],
'#type' => 'textfield',
'#size' => 20,
'#title' => $this
->t('Region'),
'#default_value' => $metadata
->getRegion() ?: '',
'#states' => [
'visible' => [
':input[name="intelligence_metadata[use_region]"]' => [
'checked' => TRUE,
],
],
],
];
$form['intelligence_metadata']['actions'] = [
'#type' => 'actions',
];
$form['intelligence_metadata']['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Save Lingotek Intelligence Metadata'),
'#button_type' => 'primary',
];
return $form;
}