public function AssemblerForm::buildForm in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.6
Same name and namespace in other branches
- 8.8 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::buildForm()
- 8.4 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::buildForm()
- 8.5 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::buildForm()
- 8.7 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::buildForm()
- 9.0.x src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::buildForm()
Return value
array Extra compoments modules.
Overrides FormInterface::buildForm
File
- src/
Form/ AssemblerForm.php, line 82
Class
- AssemblerForm
- Defines form for selecting extra components for the assembler to install.
Namespace
Drupal\varbase\FormCode
public function buildForm(array $form, FormStateInterface $form_state, array &$install_state = NULL) {
$form['#title'] = $this
->t('Extra components');
$form['extra_components_introduction'] = [
'#weight' => -1,
'#prefix' => '<p>',
'#markup' => $this
->t("Install additional ready-to-use features in your site."),
'#suffix' => '</p>',
];
// Extra Features.
$extraFeatures = ConfigBit::getList('configbit/extra.components.varbase.bit.yml', 'show_extra_components', TRUE, 'dependencies', 'profile', 'varbase');
if (count($extraFeatures)) {
$form['extra_features'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Site features'),
];
foreach ($extraFeatures as $extra_feature_key => $extra_feature_info) {
$checkbox_title = '';
$checkbox_description = '';
$checkbox_selected = FALSE;
if (isset($extra_feature_info['title'])) {
$checkbox_title = $extra_feature_info['title'];
}
if (isset($extra_feature_info['description'])) {
$checkbox_description = $extra_feature_info['description'];
}
if (isset($extra_feature_info['selected'])) {
$checkbox_selected = $extra_feature_info['selected'];
}
$form['extra_features'][$extra_feature_key] = [
'#type' => 'checkbox',
'#title' => $checkbox_title,
'#description' => $checkbox_description,
'#default_value' => $checkbox_selected,
];
if (isset($extra_feature_info['config_form']) && $extra_feature_info['config_form'] == TRUE) {
$form['extra_features'][$extra_feature_key . '_config'] = [
'#type' => 'fieldset',
'#title' => $checkbox_title,
'#states' => [
'visible' => [
':input[name="' . $extra_feature_key . '"]' => [
'checked' => TRUE,
],
],
'invisible' => [
':input[name="' . $extra_feature_key . '"]' => [
'checked' => FALSE,
],
],
],
];
if (isset($extra_feature_info['formbit'])) {
$formbit_file_name = drupal_get_path('profile', 'varbase') . '/' . $extra_feature_info['formbit'];
if (file_exists($formbit_file_name)) {
include_once $formbit_file_name;
// Add configuration form element in the formbit position.
call_user_func_array($extra_feature_key . "_build_formbit", array(
&$form['extra_features'][$extra_feature_key . '_config'],
&$form_state,
&$install_state,
));
}
}
}
}
}
// Demo Content.
$demoContent = ConfigBit::getList('configbit/demo.content.varbase.bit.yml', 'show_demo', TRUE, 'dependencies', 'profile', 'varbase');
if (count($demoContent) > 0) {
$form['demo_content'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Demo content'),
];
foreach ($demoContent as $demo_content_key => $demo_content_info) {
$checkbox_title = '';
$checkbox_description = '';
$checkbox_selected = FALSE;
if (isset($demo_content_info['title'])) {
$checkbox_title = $demo_content_info['title'];
}
if (isset($demo_content_info['description'])) {
$checkbox_description = $demo_content_info['description'];
}
if (isset($demo_content_info['selected'])) {
$checkbox_selected = $demo_content_info['selected'];
}
$form['demo_content'][$demo_content_key] = [
'#type' => 'checkbox',
'#title' => $checkbox_title,
'#description' => $checkbox_description,
'#default_value' => $checkbox_selected,
];
if (isset($demo_content_info['config_form']) && $demo_content_info['config_form'] == TRUE) {
$form['demo_content'][$demo_content_key . '_config'] = [
'#type' => 'fieldset',
'#title' => $checkbox_title,
'#states' => [
'visible' => [
':input[name="' . $demo_content_key . '"]' => [
'checked' => TRUE,
],
],
'invisible' => [
':input[name="' . $demo_content_key . '"]' => [
'checked' => FALSE,
],
],
],
];
if (isset($demo_content_info['formbit'])) {
$formbit_file_name = drupal_get_path('profile', 'varbase') . '/' . $demo_content_info['formbit'];
if (file_exists($formbit_file_name)) {
include_once $formbit_file_name;
// Add configuration form element in the formbit position.
call_user_func_array($demo_content_key . "_build_formbit", array(
&$form['demo_content'][$demo_content_key . '_config'],
&$form_state,
&$install_state,
));
}
}
}
}
}
$form['actions'] = [
'continue' => [
'#type' => 'submit',
'#value' => $this
->t('Assemble and install'),
'#button_type' => 'primary',
],
'#type' => 'actions',
'#weight' => 5,
];
return $form;
}