Skip to content

Commit 67cafd7

Browse files
committed
Revert "[BUGFIX] Allow empty values in PrefillMultiFieldViewHelper"
This reverts commit 4c48fd2.
1 parent c2339f6 commit 67cafd7

File tree

1 file changed

+42
-51
lines changed

1 file changed

+42
-51
lines changed

Classes/ViewHelpers/Misc/PrefillMultiFieldViewHelper.php

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public function initializeArguments()
8888
* check
8989
* radio
9090
*
91-
* @return bool|null
91+
* @return bool
9292
* @throws Exception
9393
* @throws ExtensionConfigurationExtensionNotConfiguredException
9494
* @throws ExtensionConfigurationPathDoesNotExistException
9595
* @throws InvalidSlotException
9696
* @throws InvalidSlotReturnException
9797
*/
98-
public function render(): ?bool
98+
public function render(): bool
9999
{
100100
/** @var Field $field */
101101
$field = $this->arguments['field'];
@@ -127,47 +127,46 @@ public function render(): ?bool
127127
protected function buildSelectedValue(): void
128128
{
129129
$selected = $this->isFromMail();
130-
if ($selected === null) {
130+
if (!$selected) {
131131
$selected = $this->isFromMarker();
132132
}
133-
if ($selected === null) {
133+
if (!$selected) {
134134
$selected = $this->isFromRawMarker();
135135
}
136-
if ($selected === null) {
136+
if (!$selected) {
137137
$selected = $this->isFromFieldUid();
138138
}
139-
if ($selected === null) {
139+
if (!$selected) {
140140
$selected = $this->isFromOldPowermailFieldUid();
141141
}
142-
if ($selected === null) {
142+
if (!$selected) {
143143
$selected = $this->isFromFrontendUser();
144144
}
145-
if ($selected === null) {
145+
if (!$selected) {
146146
$selected = $this->isFromPrefillValue();
147147
}
148-
if ($selected === null) {
148+
if (!$selected) {
149149
$selected = $this->isFromTypoScriptContentObject();
150150
}
151-
if ($selected === null) {
151+
if (!$selected) {
152152
$selected = $this->isFromTypoScriptRaw();
153153
}
154-
if ($selected === null) {
154+
if (!$selected) {
155155
$selected = $this->isFromSession();
156156
}
157-
$this->setSelected($selected ?? false);
157+
$this->setSelected($selected);
158158
}
159159

160160
/**
161161
* Check if value from existing answer (for edit view)
162162
* is set to current value
163163
*
164-
* @return bool|null
164+
* @return bool
165165
*/
166-
protected function isFromMail(): ?bool
166+
protected function isFromMail(): bool
167167
{
168-
$selected = null;
168+
$selected = false;
169169
if ($this->getMail() !== null && $this->getMail()->getAnswers()) {
170-
$selected = false;
171170
foreach ($this->getMail()->getAnswers() as $answer) {
172171
if ($answer->getField() === $this->getField()) {
173172
$values = $answer->getValue();
@@ -190,13 +189,12 @@ protected function isFromMail(): ?bool
190189
* &tx_powermail_pi1[field][marker]
191190
* is current value
192191
*
193-
* @return bool|null
192+
* @return bool
194193
*/
195-
protected function isFromMarker(): ?bool
194+
protected function isFromMarker(): bool
196195
{
197-
$selected = null;
196+
$selected = false;
198197
if (isset($this->variables['field'][$this->getMarker()])) {
199-
$selected = false;
200198
if (is_array($this->variables['field'][$this->getMarker()])) {
201199
foreach (array_keys($this->variables['field'][$this->getMarker()]) as $key) {
202200
if ($this->variables['field'][$this->getMarker()][$key] === $this->options[$this->index]['value'] ||
@@ -222,13 +220,12 @@ protected function isFromMarker(): ?bool
222220
* &tx_powermail_pi1[marker]
223221
* is current value
224222
*
225-
* @return bool|null
223+
* @return bool
226224
*/
227-
protected function isFromRawMarker(): ?bool
225+
protected function isFromRawMarker(): bool
228226
{
229-
$selected = null;
227+
$selected = false;
230228
if (isset($this->variables[$this->getMarker()])) {
231-
$selected = false;
232229
if (is_array($this->variables[$this->getMarker()])) {
233230
foreach (array_keys($this->variables[$this->getMarker()]) as $key) {
234231
if ($this->variables[$this->getMarker()][$key] === $this->options[$this->index]['value'] ||
@@ -254,14 +251,13 @@ protected function isFromRawMarker(): ?bool
254251
* &tx_powermail_pi1[field][123]
255252
* is current value
256253
*
257-
* @return bool|null
254+
* @return bool
258255
*/
259-
protected function isFromFieldUid(): ?bool
256+
protected function isFromFieldUid(): bool
260257
{
261-
$selected = null;
258+
$selected = false;
262259
$fieldUid = $this->getField()->getUid();
263260
if (isset($this->variables['field'][$fieldUid])) {
264-
$selected = false;
265261
if (is_array($this->variables['field'][$fieldUid])) {
266262
foreach (array_keys($this->variables['field'][$fieldUid]) as $key) {
267263
if ($this->variables['field'][$fieldUid][$key] === $this->options[$this->index]['value'] ||
@@ -285,13 +281,12 @@ protected function isFromFieldUid(): ?bool
285281
* Check if value from GET/POST param &tx_powermail_pi1[uid123]
286282
* is set to current value
287283
*
288-
* @return bool|null
284+
* @return bool
289285
*/
290-
protected function isFromOldPowermailFieldUid(): ?bool
286+
protected function isFromOldPowermailFieldUid(): bool
291287
{
292-
$selected = null;
288+
$selected = false;
293289
if (isset($this->variables['uid' . $this->getField()->getUid()])) {
294-
$selected = false;
295290
if ($this->variables['uid' . $this->getField()->getUid()] === $this->options[$this->index]['value'] ||
296291
$this->variables['uid' . $this->getField()->getUid()] === $this->options[$this->index]['label']
297292
) {
@@ -304,14 +299,13 @@ protected function isFromOldPowermailFieldUid(): ?bool
304299
/**
305300
* Get value from current logged in Frontend User
306301
*
307-
* @return bool|null
302+
* @return bool
308303
*/
309-
protected function isFromFrontendUser(): ?bool
304+
protected function isFromFrontendUser(): bool
310305
{
311-
$selected = null;
306+
$selected = false;
312307
$feUserValue = $this->getField()->getFeuserValue();
313308
if ($feUserValue && FrontendUtility::isLoggedInFrontendUser()) {
314-
$selected = false;
315309
if (FrontendUtility::getPropertyFromLoggedInFrontendUser($feUserValue)
316310
=== $this->options[$this->index]['value'] ||
317311
FrontendUtility::getPropertyFromLoggedInFrontendUser($feUserValue)
@@ -326,11 +320,11 @@ protected function isFromFrontendUser(): ?bool
326320
/**
327321
* Get value from prefill value from field record
328322
*
329-
* @return bool|null
323+
* @return bool
330324
*/
331-
protected function isFromPrefillValue(): ?bool
325+
protected function isFromPrefillValue(): bool
332326
{
333-
$selected = null;
327+
$selected = false;
334328
if ($this->options[$this->index]['selected']) {
335329
$selected = true;
336330
}
@@ -341,13 +335,12 @@ protected function isFromPrefillValue(): ?bool
341335
* Get from raw TypoScript settings like
342336
* plugin.tx_powermail.settings.setup.prefill.marker = red
343337
*
344-
* @return bool|null
338+
* @return bool
345339
*/
346-
protected function isFromTypoScriptRaw(): ?bool
340+
protected function isFromTypoScriptRaw(): bool
347341
{
348-
$selected = null;
342+
$selected = false;
349343
if (!empty($this->configuration['prefill.'][$this->getMarker()])) {
350-
$selected = false;
351344
if ($this->configuration['prefill.'][$this->getMarker()] === $this->options[$this->index]['value'] ||
352345
$this->configuration['prefill.'][$this->getMarker()] === $this->options[$this->index]['label']
353346
) {
@@ -360,14 +353,13 @@ protected function isFromTypoScriptRaw(): ?bool
360353
/**
361354
* Get value from session if defined in TypoScript
362355
*
363-
* @return bool|null
356+
* @return bool
364357
*/
365-
protected function isFromSession(): ?bool
358+
protected function isFromSession(): bool
366359
{
367-
$selected = null;
360+
$selected = false;
368361
$sessionValues = SessionUtility::getSessionValuesForPrefill($this->configuration);
369362
if (!empty($sessionValues) && count($sessionValues)) {
370-
$selected = false;
371363
foreach ($sessionValues as $marker => $valueInSession) {
372364
if ($this->getMarker() === $marker) {
373365
if ($valueInSession === $this->options[$this->index]['value'] ||
@@ -392,15 +384,14 @@ protected function isFromSession(): ?bool
392384
* plugin.tx_powermail.settings.setup.prefill.marker.0 = TEXT
393385
* plugin.tx_powermail.settings.setup.prefill.marker.0.value = red
394386
*
395-
* @return bool|null
387+
* @return bool
396388
*/
397-
protected function isFromTypoScriptContentObject(): ?bool
389+
protected function isFromTypoScriptContentObject(): bool
398390
{
399-
$selected = null;
391+
$selected = false;
400392
if (isset($this->configuration['prefill.'][$this->getMarker() . '.']) &&
401393
is_array($this->configuration['prefill.'][$this->getMarker() . '.'])
402394
) {
403-
$selected = false;
404395
$this->contentObjectRenderer->start(ObjectAccess::getGettableProperties($this->getField()));
405396
// Multivalue
406397
if (isset($this->configuration['prefill.'][$this->getMarker() . '.']['0'])) {

0 commit comments

Comments
 (0)