Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
46ad1e67
Commit
46ad1e67
authored
Nov 27, 2019
by
Carsten Rose
Browse files
Refs 8091 - changes to render multi checkboxes with same name. Broken.
parent
76a15545
Pipeline
#2777
passed with stages
in 2 minutes and 44 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Core/AbstractBuildForm.php
View file @
46ad1e67
...
...
@@ -2159,7 +2159,7 @@ abstract class AbstractBuildForm {
$attributeBase
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attributeBase
.
=
$this
->
getAttributeList
(
$formElement
,
[
F_FE_DATA_PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA_ERROR
]);
$key
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
'h'
);
$key
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
'h'
,
true
);
$htmlHidden
=
$this
->
buildNativeHidden
(
$key
,
''
);
$this
->
fillStoreAdditionalFormElementsCheckboxHidden
(
$formElement
,
$htmlFormElementName
,
$htmlHidden
);
...
...
@@ -2173,13 +2173,13 @@ abstract class AbstractBuildForm {
for
(
$ii
=
0
,
$jj
=
1
;
$ii
<
count
(
$itemKey
);
$ii
++
,
$jj
++
)
{
$jsonValue
=
false
;
$classActive
=
''
;
$htmlFormElementNameUniq
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
$ii
);
$htmlFormElementNameUniq
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
$ii
,
true
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$formElement
[
FE_HTML_ID
]
.
'-'
.
$ii
);
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementNameUniq
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]
.
'-'
.
$ii
);
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$itemKey
[
$ii
]);
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$itemKey
[
$ii
]
,
false
);
// Check if the given key is found in field.
if
(
false
!==
array_search
(
$itemKey
[
$ii
],
$values
))
{
...
...
@@ -2234,10 +2234,9 @@ abstract class AbstractBuildForm {
$attributeBase
.
=
Support
::
doAttribute
(
'data-load'
,
(
$formElement
[
FE_DYNAMIC_UPDATE
]
===
'yes'
)
?
'data-load'
:
''
);
$attributeBase
.
=
$this
->
getAttributeList
(
$formElement
,
[
F_FE_DATA_PATTERN_ERROR
,
F_FE_DATA_REQUIRED_ERROR
,
F_FE_DATA_MATCH_ERROR
,
F_FE_DATA_ERROR
]);
$key
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
'h'
);
$htmlHidden
=
$this
->
buildNativeHidden
(
$key
,
''
);
$this
->
fillStoreAdditionalFormElementsCheckboxHidden
(
$formElement
,
$htmlFormElementName
,
$htmlHidden
);
# $key = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, 'h');
# $htmlHidden = $this->buildNativeHidden($key, '');
# $this->fillStoreAdditionalFormElementsCheckboxHidden($formElement, $htmlFormElementName, $htmlHidden);
$html
=
''
;
...
...
@@ -2249,7 +2248,7 @@ abstract class AbstractBuildForm {
for
(
$ii
=
0
,
$jj
=
1
;
$ii
<
count
(
$itemKey
);
$ii
++
,
$jj
++
)
{
$jsonValue
=
false
;
$attribute
=
$attributeBase
;
$htmlFormElementNameUniq
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
$ii
);
$htmlFormElementNameUniq
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$htmlFormElementName
,
$ii
,
true
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$formElement
[
FE_HTML_ID
]
.
'-'
.
$ii
);
$attribute
.
=
Support
::
doAttribute
(
'name'
,
$htmlFormElementNameUniq
);
$attribute
.
=
Support
::
doAttribute
(
ATTRIBUTE_DATA_REFERENCE
,
$formElement
[
FE_DATA_REFERENCE
]
.
'-'
.
$ii
);
...
...
@@ -2261,7 +2260,7 @@ abstract class AbstractBuildForm {
$attribute
.
=
Support
::
doAttribute
(
'autofocus'
,
$formElement
[
FE_AUTOFOCUS
]);
}
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$itemKey
[
$ii
]);
$attribute
.
=
Support
::
doAttribute
(
'value'
,
$itemKey
[
$ii
]
,
false
);
// Check if the given key is found in field.
if
(
false
!==
array_search
(
$itemKey
[
$ii
],
$values
))
{
...
...
extension/Classes/Core/Helper/HelperFormElement.php
View file @
46ad1e67
...
...
@@ -207,10 +207,17 @@ class HelperFormElement {
* @param string $field
* @param string $index
*
* @param bool $appendArray
* @return string
*/
public
static
function
prependFormElementNameCheckBoxMulti
(
$field
,
$index
)
{
return
'_'
.
$index
.
'_'
.
$field
;
public
static
function
prependFormElementNameCheckBoxMulti
(
$field
,
$index
,
$appendArray
=
false
)
{
// return '_' . $index . '_' . $field;
$key
=
'_'
.
$field
;
if
(
$appendArray
)
{
$key
.
=
'[]'
;
}
return
$key
;
}
/**
...
...
extension/Classes/Core/Store/FillStoreForm.php
View file @
46ad1e67
...
...
@@ -12,7 +12,6 @@ use IMATHUZH\Qfq\Core\Database\Database;
use
IMATHUZH\Qfq\Core\Evaluate
;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
use
IMATHUZH\Qfq\Core\Helper\Logger
;
use
IMATHUZH\Qfq\Core\Helper\Sanitize
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
...
...
@@ -280,7 +279,7 @@ class FillStoreForm {
// FORM_REST: typically form elements are filled and created on form load. This does not exist for REST Forms.
// If a FE.value is defined, this has precedence over client supplied content.
if
(
$formMode
==
FORM_REST
&&
$formElement
[
FE_VALUE
]
!=
''
)
{
if
(
$formMode
==
FORM_REST
&&
$formElement
[
FE_VALUE
]
!=
''
)
{
$clientValues
[
$clientFieldName
]
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_VALUE
]);
}
...
...
@@ -354,7 +353,19 @@ class FillStoreForm {
*/
private
function
collectMultiValues
(
$clientFieldName
,
array
$clientValues
)
{
$checkboxKey
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$clientFieldName
,
'h'
);
$checkboxKey
=
HelperFormElement
::
prependFormElementNameCheckBoxMulti
(
$clientFieldName
,
''
,
false
);
if
(
!
isset
(
$clientValues
[
$checkboxKey
]))
{
return
''
;
}
// single: no array, multi: array
if
(
!
is_array
(
$clientValues
[
$checkboxKey
]))
{
return
false
;
}
return
implode
(
','
,
$clientValues
[
$checkboxKey
]);
// For templateGroups: all expanded FormElements will be tried to collect - this fails for not submitted fields.
// Therefore skip not existing clientvalues.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment