WebformFlexbox.php in Webform 6.x
File
src/Plugin/WebformElement/WebformFlexbox.php
View source
<?php
namespace Drupal\webform\Plugin\WebformElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformSubmissionInterface;
class WebformFlexbox extends Container {
protected function defineDefaultProperties() {
return [
'align_items' => 'flex-start',
] + parent::defineDefaultProperties();
}
protected function build($format, array &$element, WebformSubmissionInterface $webform_submission, array $options = []) {
$view_builder = $this->entityTypeManager
->getViewBuilder('webform_submission');
return $view_builder
->buildElements($element, $webform_submission, $options, $format);
}
public function preview() {
return [];
}
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['flexbox'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Flexbox settings'),
];
$form['flexbox']['align_items'] = [
'#type' => 'select',
'#title' => $this
->t('Align items'),
'#options' => [
'flex-start' => $this
->t('Top (flex-start)'),
'flex-end' => $this
->t('Bottom (flex-end)'),
'center' => $this
->t('Center (center)'),
],
'#required' => TRUE,
];
return $form;
}
}