This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be8d44b
commit d8924c2
Showing
3 changed files
with
90 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Drupal\starshot_installer\Form; | ||
|
||
use Drupal\Core\Form\FormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Provides the recipe add-on selection form. | ||
*/ | ||
final class RecipesForm extends FormBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId(): string { | ||
return 'starshot_installer_recipes_form'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state): array { | ||
$form['#title'] = $this->t('Choose template & add-ons'); | ||
|
||
$form['template'] = [ | ||
'#type' => 'radios', | ||
'#title' => $this->t('Choose your site template'), | ||
'#options' => [ | ||
'starshot' => $this->t('Starshot'), | ||
], | ||
'#required' => TRUE, | ||
'#default_value' => 'starshot', | ||
]; | ||
|
||
$options = [ | ||
'starshot_multilingual' => $this->t('Multilingual support'), | ||
'starshot_accessibility_tools' => $this->t('Accessibility tools'), | ||
]; | ||
|
||
$form['add_ons'] = [ | ||
'#type' => 'checkboxes', | ||
'#title' => $this->t('Optional add-ons'), | ||
'#options' => $options, | ||
'#default_value' => [], | ||
]; | ||
|
||
$form['actions'] = [ | ||
'submit' => [ | ||
'#type' => 'submit', | ||
'#value' => $this->t('Save and continue'), | ||
'#button_type' => 'primary', | ||
], | ||
'#type' => 'actions', | ||
]; | ||
return $form; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state): void { | ||
global $install_state; | ||
|
||
$add_ons = $form_state->getValue('add_ons', []); | ||
$add_ons = array_filter($add_ons); | ||
|
||
$install_state['parameters']['recipes'] = [ | ||
$form_state->getValue('template'), | ||
...array_values($add_ons), | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters