public function SimplenewsSubscriptionBlock::blockForm in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/Block/SimplenewsSubscriptionBlock.php \Drupal\simplenews\Plugin\Block\SimplenewsSubscriptionBlock::blockForm()
- 8 src/Plugin/Block/SimplenewsSubscriptionBlock.php \Drupal\simplenews\Plugin\Block\SimplenewsSubscriptionBlock::blockForm()
Overrides BlockPluginTrait::blockForm
File
- src/
Plugin/ Block/ SimplenewsSubscriptionBlock.php, line 96
Class
- SimplenewsSubscriptionBlock
- Provides a subscription block with all available newsletters and email field.
Namespace
Drupal\simplenews\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
foreach (simplenews_newsletter_get_visible() as $newsletter) {
$options[$newsletter
->id()] = $newsletter->name;
}
$form['newsletters'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Newsletters'),
'#options' => $options,
'#required' => TRUE,
'#default_value' => $this->configuration['newsletters'],
];
$form['message'] = [
'#type' => 'textfield',
'#title' => $this
->t('Block message'),
'#size' => 60,
'#maxlength' => 255,
'#default_value' => $this->configuration['message'],
];
$form['unique_id'] = [
'#type' => 'textfield',
'#title' => $this
->t('Unique ID'),
'#size' => 60,
'#maxlength' => 255,
'#description' => $this
->t('Each subscription block must have a unique form ID. If no value is provided, a random ID will be generated. Use this to have a predictable, short ID, e.g. to configure this form use a CAPTCHA.'),
'#default_value' => $this->configuration['unique_id'],
];
// @codingStandardsIgnoreStart
/*if (\Drupal::moduleHandler()->moduleExists('views')) {
$form['link_previous'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Display link to previous issues'),
'#return_value' => 1,
'#default_value' => variable_get('simplenews_block_l_' . $delta, 1),
'#description' => $this->t('Link points to newsletter/newsletter_id, which is provided by the newsletter issue list default view.'),
);
}*/
/*if (\Drupal::moduleHandler()->moduleExists('views')) {
$form['rss_feed'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Display RSS-feed icon'),
'#return_value' => 1,
'#default_value' => variable_get('simplenews_block_r_' . $delta, 1),
'#description' => $this->t('Link points to newsletter/feed/newsletter_id, which is provided by the newsletter issue list default view.'),
);
}*/
// @codingStandardsIgnoreEnd
return $form;
}