public function BlockFieldWidget::formElement in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.2 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.3 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.4 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.5 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.6 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.7 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 8.8 modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 10.0.x modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 10.1.x modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
- 10.2.x modules/social_features/social_landing_page/src/Plugin/Field/FieldWidget/BlockFieldWidget.php \Drupal\social_landing_page\Plugin\Field\FieldWidget\BlockFieldWidget::formElement()
File
- modules/
social_features/ social_landing_page/ src/ Plugin/ Field/ FieldWidget/ BlockFieldWidget.php, line 25
Class
- BlockFieldWidget
- Plugin implementation of the 'block_field' widget.
Namespace
Drupal\social_landing_page\Plugin\Field\FieldWidgetCode
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
if ($element['#field_parents'][0] != 'field_landing_page_section') {
return $element;
}
$options = [];
$groups = [
$this
->t('Lists (Views)')
->render() => $this
->t('Basic'),
$this
->t('Social Landing Page')
->render() => $this
->t('Basic'),
];
$blocks = [
'activity_overview_block' => $this
->t('Community statistics'),
'views_block:activity_stream-block_stream_homepage_without_post' => $this
->t('Personalised activity stream'),
'views_block:activity_stream-block_stream_homepage' => $this
->t('Personalised activity stream (with post form)'),
'views_block:community_activities-block_stream_landing' => $this
->t('Complete community activity stream'),
'views_block:community_activities-block_stream_landing_with_post' => $this
->t('Complete community activity stream (with post form)'),
'views_block:latest_topics-block_latest_topics' => $this
->t('Latest topics'),
'views_block:newest_groups-block_newest_groups' => $this
->t('Newest groups'),
'views_block:newest_users-block_newest_users' => $this
->t('Newest users'),
'views_block:upcoming_events-block_community_events' => $this
->t('Upcoming community events'),
];
foreach ($element['plugin_id']['#options'] as $title => $items) {
if (isset($groups[$title])) {
$title = $groups[$title];
}
else {
$title = $this
->t('Extra');
}
$title = $title
->render();
if (!isset($options[$title])) {
$options[$title] = [];
}
foreach ($items as $key => $value) {
if (isset($blocks[$key])) {
$value = $blocks[$key];
}
$options[$title][$key] = $value;
}
}
foreach ($options as &$option) {
asort($option);
}
$element['plugin_id']['#options'] = $options;
return $element;
}