public function ContactFormBlock::blockForm in Form Block 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/Block/ContactFormBlock.php \Drupal\formblock\Plugin\Block\ContactFormBlock::blockForm()
Overrides \Drupal\block\BlockBase::blockForm().
Overrides BlockPluginTrait::blockForm
File
- src/
Plugin/ Block/ ContactFormBlock.php, line 150
Class
- ContactFormBlock
- Provides a block for contact form.
Namespace
Drupal\formblock\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$categories = $this->entityTypeManager
->getStorage('contact_form')
->loadMultiple();
$options = [];
foreach ($categories as $category) {
$options[$category
->id()] = $category
->label();
}
$form['formblock_contact_form'] = [
'#type' => 'select',
'#title' => $this
->t('Category'),
'#default_value' => $this->configuration['contact_form'],
'#description' => $this
->t('Select the category to show.'),
'#options' => $options,
'#required' => TRUE,
];
return $form;
}