Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
bffc45b1
Commit
bffc45b1
authored
Sep 23, 2019
by
Carsten Rose
Browse files
MultiForm Save - successful in simple way
parent
234ee19c
Pipeline
#2403
passed with stages
in 2 minutes and 57 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Core/AbstractBuildForm.php
View file @
bffc45b1
...
...
@@ -226,10 +226,7 @@ abstract class AbstractBuildForm {
}
// Check for 'id' or '_id' as column name
$idName
=
F_MULTI_COL_ID
;
if
(
isset
(
$parentRecords
[
0
][
'_'
.
F_MULTI_COL_ID
]))
{
$idName
=
'_'
.
F_MULTI_COL_ID
;
}
$idName
=
isset
(
$parentRecords
[
0
][
'_'
.
F_MULTI_COL_ID
])
?
'_'
.
F_MULTI_COL_ID
:
F_MULTI_COL_ID
;
// Check that an column 'id' is given
if
(
!
isset
(
$parentRecords
[
0
][
$idName
]))
{
...
...
@@ -281,6 +278,8 @@ abstract class AbstractBuildForm {
/**
* @param array $row
* @return string
* @throws \CodeException
* @throws \UserFormException
*/
private
function
buildMultiFormTableHead
(
array
$row
)
{
$line
=
''
;
...
...
@@ -293,8 +292,19 @@ abstract class AbstractBuildForm {
}
// Collect label from FormElements
foreach
(
$this
->
feSpecNative
as
$fe
)
{
$line
.
=
'<th>'
.
$fe
[
FE_LABEL
]
.
'</th>'
;
foreach
(
$this
->
feSpecNative
as
$formElement
)
{
$editFeHtml
=
''
;
// debugStack as Tooltip
if
(
$this
->
showDebugInfoFlag
)
{
// Build 'FormElement' Edit symbol
$feEditUrl
=
$this
->
createFormEditorUrl
(
FORM_NAME_FORM_ELEMENT
,
$formElement
[
FE_ID
],
[
'formId'
=>
$formElement
[
FE_FORM_ID
]]);
$titleAttr
=
Support
::
doAttribute
(
'title'
,
$this
->
formSpec
[
FE_NAME
]
.
' / '
.
$formElement
[
FE_NAME
]
.
' ['
.
$formElement
[
FE_ID
]
.
']'
);
$icon
=
Support
::
wrapTag
(
'<span class="'
.
GLYPH_ICON
.
' '
.
GLYPH_ICON_EDIT
.
'">'
,
''
);
$editFeHtml
=
' '
.
Support
::
wrapTag
(
"<a class='hidden "
.
CLASS_FORM_ELEMENT_EDIT
.
"' href='
$feEditUrl
'
$titleAttr
>"
,
$icon
);
}
$line
.
=
'<th>'
.
$formElement
[
FE_LABEL
]
.
$editFeHtml
.
'</th>'
;
}
return
$line
;
...
...
@@ -392,7 +402,7 @@ abstract class AbstractBuildForm {
}
/**
* Build
s
the head area of the form.
* Build the head area of the form.
*
* @param string $mode
* @return string
...
...
@@ -845,16 +855,19 @@ abstract class AbstractBuildForm {
if
(
$flagOutput
)
{
// debugStack as Tooltip
if
(
$this
->
showDebugInfoFlag
&&
!
$flagMulti
)
{
if
(
$this
->
showDebugInfoFlag
)
{
if
(
count
(
$debugStack
)
>
0
)
{
$elementHtml
.
=
Support
::
doTooltip
(
$formElement
[
FE_HTML_ID
]
.
HTML_ID_EXTENSION_TOOLTIP
,
implode
(
"
\n
"
,
$debugStack
));
}
// Build 'FormElement' Edit symbol
$feEditUrl
=
$this
->
createFormEditorUrl
(
FORM_NAME_FORM_ELEMENT
,
$formElement
[
FE_ID
],
[
'formId'
=>
$formElement
[
FE_FORM_ID
]]);
$titleAttr
=
Support
::
doAttribute
(
'title'
,
$this
->
formSpec
[
FE_NAME
]
.
' / '
.
$formElement
[
FE_NAME
]
.
' ['
.
$formElement
[
FE_ID
]
.
']'
);
$icon
=
Support
::
wrapTag
(
'<span class="'
.
GLYPH_ICON
.
' '
.
GLYPH_ICON_EDIT
.
'">'
,
''
);
$elementHtml
.
=
Support
::
wrapTag
(
"<a class='hidden "
.
CLASS_FORM_ELEMENT_EDIT
.
"' href='
$feEditUrl
'
$titleAttr
>"
,
$icon
);
if
(
!
$flagMulti
)
{
// Build 'FormElement' Edit symbol. MultiForms: Edit symbol is in thead.
$feEditUrl
=
$this
->
createFormEditorUrl
(
FORM_NAME_FORM_ELEMENT
,
$formElement
[
FE_ID
],
[
'formId'
=>
$formElement
[
FE_FORM_ID
]]);
$titleAttr
=
Support
::
doAttribute
(
'title'
,
$this
->
formSpec
[
FE_NAME
]
.
' / '
.
$formElement
[
FE_NAME
]
.
' ['
.
$formElement
[
FE_ID
]
.
']'
);
$icon
=
Support
::
wrapTag
(
'<span class="'
.
GLYPH_ICON
.
' '
.
GLYPH_ICON_EDIT
.
'">'
,
''
);
$elementHtml
.
=
Support
::
wrapTag
(
"<a class='hidden "
.
CLASS_FORM_ELEMENT_EDIT
.
"' href='
$feEditUrl
'
$titleAttr
>"
,
$icon
);
}
}
// Construct Marshaller Name: buildRow...
...
...
extension/Classes/Core/Save.php
View file @
bffc45b1
...
...
@@ -9,15 +9,15 @@
namespace
IMATHUZH\Qfq\Core
;
use
IMATHUZH\Qfq\Core\Database\Database
;
use
IMATHUZH\Qfq\Core\Helper\HelperFile
;
use
IMATHUZH\Qfq\Core\Helper\HelperFormElement
;
use
IMATHUZH\Qfq\Core\Helper\Logger
;
use
IMATHUZH\Qfq\Core\Helper\OnArray
;
use
IMATHUZH\Qfq\Core\Helper\Sanitize
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
use
IMATHUZH\Qfq\Core\Store\Store
;
use
IMATHUZH\Qfq\Core\Store\Sip
;
use
IMATHUZH\Qfq\Core\
Helper\HelperFil
e
;
use
IMATHUZH\Qfq\Core\
Helper\OnArray
;
use
IMATHUZH\Qfq\Core\
Store\Stor
e
;
use
IMATHUZH\Qfq\Core\
Store\FillStoreForm
;
/**
* Class Save
...
...
@@ -70,17 +70,13 @@ class Save {
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
public
function
process
()
{
$rc
=
0
;
if
(
$this
->
formSpec
[
F_MULTI_SQL
]
!==
''
)
{
$parentRecords
=
$this
->
db
->
sql
(
$this
->
formSpec
[
F_MULTI_SQL
]);
foreach
(
$parentRecords
as
$row
)
{
$this
->
store
->
setStore
(
$row
,
STORE_PARENT_RECORD
,
true
);
$rc
=
$this
->
elements
(
$row
[
'_id'
]);
}
$rc
=
$this
->
saveMultiForm
();
}
else
{
$recordId
=
$this
->
store
->
getVar
(
SIP_RECORD_ID
,
STORE_SIP
.
STORE_ZERO
);
$rc
=
$this
->
elements
(
$recordId
);
...
...
@@ -89,6 +85,48 @@ class Save {
return
$rc
;
}
/**
* @return int|string
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
private
function
saveMultiForm
()
{
$parentRecords
=
$this
->
evaluate
->
parse
(
$this
->
formSpec
[
F_MULTI_SQL
],
ROW_REGULAR
);
// No rows: nothing to do.
if
(
empty
(
$parentRecords
))
{
//TODO Meldung konfigurierbar machen.
return
'No data'
;
}
// Check for 'id' or '_id' as column name
$idName
=
isset
(
$parentRecords
[
0
][
'_'
.
F_MULTI_COL_ID
])
?
'_'
.
F_MULTI_COL_ID
:
F_MULTI_COL_ID
;
// Check that an column 'id' is given
if
(
!
isset
(
$parentRecords
[
0
][
$idName
]))
{
throw
new
\
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Missing column "_'
.
F_MULTI_COL_ID
.
'"'
,
ERROR_MESSAGE_TO_DEVELOPER
=>
$this
->
formSpec
[
F_MULTI_SQL
]]),
ERROR_INVALID_OR_MISSING_PARAMETER
);
}
$fillStoreForm
=
new
FillStoreForm
();
foreach
(
$parentRecords
as
$row
)
{
$this
->
store
->
setStore
(
$row
,
STORE_PARENT_RECORD
,
true
);
// Fake current recordId
$this
->
store
->
setVar
(
SIP_RECORD_ID
,
$row
[
$idName
],
STORE_SIP
);
$fillStoreForm
->
process
(
FORM_SAVE
);
$rc
=
$this
->
elements
(
$row
[
$idName
]);
}
return
$rc
;
}
/**
* Create empty FormElements based on templateGroups, for those who not already exist.
*
...
...
@@ -176,7 +214,7 @@ class Save {
* @throws \UserFormException
* @throws \DbException
*/
p
ublic
function
elements
(
$recordId
)
{
p
rivate
function
elements
(
$recordId
)
{
$columnCreated
=
false
;
$columnModified
=
false
;
...
...
extension/Classes/Core/Store/FillStoreForm.php
View file @
bffc45b1
...
...
@@ -345,7 +345,7 @@ class FillStoreForm {
/**
* Steps through all $clientValues (POST vars) and collect all with the name _?_${clientFieldName} in a comma
* sep
e
rated string (MYSQL ENUM type). If there is no element '_h_${clientFieldName}', than there are no multi
* sep
a
rated string (MYSQL ENUM type). If there is no element '_h_${clientFieldName}', than there are no multi
* values - return the already given `$clientValues[$clientFieldName]`.
*
* @param $clientFieldName
...
...
Write
Preview
Markdown
is supported
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