public function TmgmtSmartlingContextDebugForm::buildForm in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8 modules/tmgmt_smartling_context_debug/src/Form/TmgmtSmartlingContextDebugForm.php \Drupal\tmgmt_smartling_context_debug\Form\TmgmtSmartlingContextDebugForm::buildForm()
- 8.2 modules/tmgmt_smartling_context_debug/src/Form/TmgmtSmartlingContextDebugForm.php \Drupal\tmgmt_smartling_context_debug\Form\TmgmtSmartlingContextDebugForm::buildForm()
- 8.3 modules/tmgmt_smartling_context_debug/src/Form/TmgmtSmartlingContextDebugForm.php \Drupal\tmgmt_smartling_context_debug\Form\TmgmtSmartlingContextDebugForm::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
- modules/
tmgmt_smartling_context_debug/ src/ Form/ TmgmtSmartlingContextDebugForm.php, line 26
Class
- TmgmtSmartlingContextDebugForm
- Form that helps to debug Smartling Context.
Namespace
Drupal\tmgmt_smartling_context_debug\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$configs = [];
$smartling_provider_configs = \Drupal::getContainer()
->get('tmgmt_smartling.smartling_config_manager')
->getAvailableConfigs();
foreach ($smartling_provider_configs as $smartling_provider_config) {
$configs[$smartling_provider_config
->getName()] = $smartling_provider_config
->get('label');
}
if (empty($configs)) {
return [
'#markup' => $this
->t('No Smartling configs found. Please create Smartling config first'),
];
}
$form['smartling_config'] = [
'#type' => 'select',
'#options' => $configs,
'#title' => $this
->t('Smartling configs'),
'#default_value' => key($configs),
'#description' => $this
->t('Context related options will be read from specified config.'),
];
$form['do_direct_output'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show the context snapshot of the page in a browser.'),
'#description' => 'If checked, the context will be shown on this page instead of being sent to Smartling.',
'#default_value' => FALSE,
'#required' => FALSE,
];
$form['filename'] = [
'#type' => 'textfield',
'#title' => t('FileName'),
'#description' => t('FileName of a Job'),
'#default_value' => '',
'#size' => 25,
'#maxlength' => 25,
];
$form['url'] = [
'#type' => 'textfield',
'#title' => t('URL'),
'#description' => t('URL of the page to extract the context for'),
'#default_value' => '',
'#size' => 25,
'#maxlength' => 125,
'#required' => TRUE,
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Test context'),
'#button_type' => 'primary',
);
return $form;
}