public function SettingsForm::buildForm in Commerce File 8.2
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 ConfigFormBase::buildForm
File
- src/
Form/ SettingsForm.php, line 43
Class
- SettingsForm
- Defines the Commerce file settings form.
Namespace
Drupal\commerce_file\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$help = $this
->t('These are the default download and IP address limits for file downloads.');
$help .= $this
->t('These limits can be overridden per product variation as needed.');
$form['help'] = [
'#markup' => $help,
];
$form['download_limits'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Download limits'),
];
// Download limit.
$form['download_limits']['enable_download_limit'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Limit the number of times a user can download a licensed file'),
'#default_value' => $this
->config('commerce_file.settings')
->get('enable_download_limit'),
];
$form['download_limits']['download_limit'] = [
'#type' => 'textfield',
'#title' => $this
->t('Enter limit'),
'#default_value' => $this
->config('commerce_file.settings')
->get('download_limit'),
'#states' => [
'invisible' => [
':input[name="enable_download_limit"]' => [
'checked' => FALSE,
],
],
],
];
return $form;
}