<?php
namespace wcf\system\form\builder\field;
+use wcf\system\form\builder\data\processor\CustomFormDataProcessor;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
+use wcf\system\form\builder\IFormDocument;
/**
* Implementation of a form field for selecting multiple values.
* @package WoltLabSuite\Core\System\Form\Builder\Field
* @since 5.2
*/
-class MultipleSelectionFormField extends AbstractFormField implements IFilterableSelectionFormField, IImmutableFormField, INullableFormField {
+class MultipleSelectionFormField extends AbstractFormField implements IFilterableSelectionFormField, IImmutableFormField {
use TFilterableSelectionFormField;
use TImmutableFormField;
- use TNullableFormField;
/**
* @inheritDoc
*/
protected $templateName = '__multipleSelectionFormField';
+ /**
+ * @inheritDoc
+ */
+ protected $value = [];
+
+ /**
+ * @inheritDoc
+ */
+ public function hasSaveValue() {
+ return false;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function populate() {
+ parent::populate();
+
+ $this->getDocument()->getDataHandler()->addProcessor(
+ new CustomFormDataProcessor(
+ 'multiple',
+ function(IFormDocument $document, array $parameters) {
+ if ($this->checkDependencies() && !empty($this->getValue())) {
+ $parameters[$this->getObjectProperty()] = $this->getValue();
+ }
+
+ return $parameters;
+ }
+ )
+ );
+
+ return $this;
+ }
+
/**
* @inheritDoc
*/
$form
);
- if (!empty($data['visibilityExceptions'])) {
+ if (!empty($formData['visibilityExceptions'])) {
$box->appendChild($document->createElement('visibleEverywhere', (string)($data['visibleEverywhere'] ?? 0)));
$visibilityExceptions = $document->createElement('visibilityExceptions');
- sort($data['visibilityExceptions']);
- foreach ($data['visibilityExceptions'] as $page) {
+ sort($formData['visibilityExceptions']);
+ foreach ($formData['visibilityExceptions'] as $page) {
$visibilityExceptions->appendChild($document->createElement('page', $page));
}
}
}
- if (!empty($formData['data']['boxVisibilityExceptions'])) {
+ if (!empty($formData['boxVisibilityExceptions'])) {
$visibilityExceptions = $box->appendChild($document->createElement('visibilityExceptions'));
- foreach ($formData['data']['boxVisibilityExceptions'] as $pageIdentifier) {
+ sort($formData['boxVisibilityExceptions']);
+ foreach ($formData['boxVisibilityExceptions'] as $pageIdentifier) {
$visibilityExceptions->appendChild($document->createElement('page', $pageIdentifier));
}
}