LayoutContainer.php in Webform Layout Container 8
File
src/Plugin/WebformElement/LayoutContainer.php
View source
<?php
namespace Drupal\webform_layout_container\Plugin\WebformElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformElement\Container;
use Drupal\webform\WebformSubmissionInterface;
class LayoutContainer extends Container {
public function getDefaultProperties() {
return parent::getDefaultProperties() + [
'align' => 'equal',
];
}
protected function build($format, array &$element, WebformSubmissionInterface $webform_submission, array $options = []) {
return $value;
}
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['layout_container'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Alignment settings'),
'#open' => TRUE,
];
$form['layout_container']['align'] = [
'#type' => 'select',
'#title' => $this
->t('Alignment'),
'#description' => $this
->t('Controls how elements are arranged in this container. Choose "horizontal" to create a row, or "equal width" to create a row with equal column widths. The "vertical" option can be used to make columns within a horizontal box.'),
'#options' => [
'horiz' => $this
->t('Horizontal'),
'equal' => $this
->t('Equal Width'),
'vert' => $this
->t('Vertical'),
],
'#required' => TRUE,
];
return $form;
}
}