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
b6b93b6f
Commit
b6b93b6f
authored
Feb 21, 2017
by
Carsten Rose
Browse files
templateGroup values load until no further values exist
parent
6327062a
Changes
1
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/AbstractBuildForm.php
View file @
b6b93b6f
...
...
@@ -2320,15 +2320,17 @@ abstract class AbstractBuildForm {
/**
* Build real FormElements based on the current templateGroup FormElements in $this->feSpecNative.
* Take a
group
, if at least one of the elements is filled with a non default value.
* Stop filling elements
at
the
first complete empty group
.
* Take a
templateGroup 'copy'
, if at least one of the elements is filled with a non default value.
* Stop filling elements
if
the
re are no further elements filled
.
*
* @param $max
* @param int $max
* @param string $htmlDelete
* @param array $json
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
private
function
templateGroupCollectFilledElements
(
$max
)
{
private
function
templateGroupCollectFilledElements
(
$max
,
$htmlDelete
,
array
&
$json
)
{
$record
=
$this
->
store
->
getStore
(
STORE_RECORD
);
// current values
if
(
$record
===
false
||
count
(
$record
)
===
0
)
{
...
...
@@ -2336,27 +2338,33 @@ abstract class AbstractBuildForm {
}
$default
=
$this
->
store
->
getStore
(
STORE_TABLE_DEFAULT
);
// current defaults
$lastFilled
=
0
;
// Marker if there is at least one element per copy who is filled.
$feSpecNativeFilled
=
array
();
for
(
$ii
=
1
;
$ii
<
$max
;
$ii
++
)
{
$flagFound
=
false
;
// Marker if there is at least one element per row who is set.
$feSpecNativeNew
=
array
();
//
I
terate over all templateGroup FormElements
//
Per copy, i
terate over all templateGroup FormElements
foreach
(
$this
->
feSpecNative
as
$fe
)
{
$columnName
=
str_replace
(
FE_TEMPLATE_GROUP_NAME_PATTERN
,
$ii
,
$fe
[
FE_NAME
]);
if
(
isset
(
$record
[
$columnName
]))
{
if
(
$record
[
$columnName
]
!=
$default
[
$columnName
])
{
$
f
la
gFound
=
true
;
$la
stFilled
=
$ii
;
}
}
else
{
throw
new
UserFormException
(
"Not implemented: templateGroup FormElement-columns
outside of
primary table."
,
ERROR_NOT_IMPLEMENTED
);
throw
new
UserFormException
(
"Not implemented: templateGroup FormElement-columns
not found in
primary table."
,
ERROR_NOT_IMPLEMENTED
);
}
$fe
[
FE_NAME
]
=
$columnName
;
$feSpecNativeNew
[]
=
$fe
;
// Build array with current copy of templateGroup.
}
if
(
!
$flagFound
)
{
break
;
// Append $htmlDelete on the last element of all copies but the first.
if
(
$ii
>
1
)
{
// Count defined FormElements in the current templateGroup
$last
=
count
(
$feSpecNativeNew
)
-
1
;
// Append 'delete' Button at the note of the last element
$feSpecNativeNew
[
$last
][
FE_NOTE
]
.
=
$htmlDelete
;
}
$feSpecNativeFilled
=
array_merge
(
$feSpecNativeFilled
,
$feSpecNativeNew
);
...
...
@@ -2367,9 +2375,11 @@ abstract class AbstractBuildForm {
return
''
;
}
// Take all copies upto the last filled element.
$feSpecNativeFilled
=
array_slice
(
$feSpecNativeFilled
,
0
,
$lastFilled
*
count
(
$this
->
feSpecNative
));
$feSpecNativeSave
=
$this
->
feSpecNative
;
$this
->
feSpecNative
=
$feSpecNativeFilled
;
$json
=
array
();
$html
=
$this
->
elements
(
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
),
FORM_ELEMENTS_NATIVE
,
0
,
$json
);
$this
->
feSpecNative
=
$feSpecNativeSave
;
...
...
@@ -2377,7 +2387,8 @@ abstract class AbstractBuildForm {
}
/**
* Build a HTML fieldset. Renders all assigned FormElements inside the fieldset.
* Build a 'templateGroup'. Renders all assigned FormElements of the templateGroup.
* If there are already vlaues for the formElements, fill as much copies as values exist
*
* @param array $formElement
* @param $htmlFormElementId
...
...
@@ -2435,7 +2446,7 @@ EOT;
// Count defined FormElements in the current templateGroup
$last
=
count
(
$this
->
feSpecNative
)
-
1
;
if
(
$last
<
1
)
{
if
(
$last
<
0
)
{
$this
->
feSpecNative
=
$feSpecNativeSave
;
return
''
;
}
...
...
@@ -2443,7 +2454,7 @@ EOT;
$this
->
feSpecNative
[
$last
][
FE_NOTE
]
.
=
$htmlDelete
;
// If there are already elements filled, take them.
$html
=
$this
->
templateGroupCollectFilledElements
(
$max
);
$html
=
$this
->
templateGroupCollectFilledElements
(
$max
,
$htmlDelete
,
$json
);
$attribute
=
Support
::
doAttribute
(
'class'
,
$qfqFieldsName
);
$attribute
.
=
Support
::
doAttribute
(
'id'
,
$targetName
);
...
...
@@ -2451,6 +2462,7 @@ EOT;
// Element where the effective FormElements will be copied to. The BS 'col-md-* Classes are inside the template, not here. This here should be pure data without wrapping.
$html
=
Support
::
wrapTag
(
"<div
$attribute
>"
,
$html
,
false
);
// Add button, row below: The label & note of the FormElement 'templateGroup' will be used for the add button row.
$tmpFe
=
$formElement
;
$tmpFe
[
FE_NAME
]
=
'_add'
;
...
...
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