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
15439f12
Commit
15439f12
authored
Oct 13, 2019
by
Carsten Rose
Browse files
Implements #5695 - respect '{{slaveId:V}}' if it is given.
parent
324d4549
Pipeline
#2472
passed with stages
in 2 minutes and 41 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Documentation/Manual.rst
View file @
15439f12
...
...
@@ -4136,10 +4136,14 @@ Parameter: slaveId
Note:
* `{{slaveId}}` can be used in any query of the current *FormElement*.
* `{{slaveId
:V
}}` can be used in any query of the current *FormElement*.
* If the `action`-*FormElement* name exist as a column in the master record: Update that column *automatically* with the
recent slaveId
* After an INSERT the `last_insert_id()` becomes the *slaveId*).
* After an INSERT the `last_insert_id()` becomes the *{{slaveId:V}}*.
* `fillStoreVar` is fired first, than `slaveId`.
* If `slaveId` is known in `fillStoreVar`, set: `slaveId={{someId:V}}`.
Parameter: sqlBefore / sqlInsert / sqlUpdate / sqlDelete / sqlAfter
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
...
...
extension/Classes/Core/Form/FormAction.php
View file @
15439f12
...
...
@@ -69,6 +69,8 @@ class FormAction {
}
/**
* Parse $fillStoreVar and if something is given, add it to STORE_VAR.
*
* @param string $fillStoreVar
* @throws \CodeException
* @throws \DbException
...
...
@@ -378,6 +380,12 @@ class FormAction {
// Store the slaveId: it's used and replaced in the update statement.
$this
->
store
->
setVar
(
VAR_SLAVE_ID
,
$slaveId
,
STORE_VAR
,
true
);
}
else
{
if
(
false
!==
(
$id
=
$this
->
store
->
getVar
(
VAR_SLAVE_ID
,
STORE_VAR
)))
{
$slaveId
=
$id
;
$fe
[
FE_SLAVE_ID
]
=
$id
;
}
}
// If given: fire a sqlBefore query
...
...
extension/Tests/Unit/Core/SaveTest.php
View file @
15439f12
...
...
@@ -160,11 +160,6 @@ class SaveTest extends AbstractDatabaseTest {
[
FE_ID
=>
1
,
FE_TYPE
=>
FE_TYPE_TEXT
,
FE_NAME
=>
'name'
,
],
[
FE_ID
=>
2
,
FE_TYPE
=>
FE_TYPE_TEXT
,
FE_NAME
=>
'firstName'
,
FE_SQL_BEFORE
=>
'{{UPDATE Address SET city=CONCAT(city, "-") WHERE id={{slaveId:V}} }}'
,
FE_SLAVE_ID
=>
'{{SELECT id FROM Address WHERE street="deleteMe"}}'
,
...
...
@@ -218,6 +213,40 @@ class SaveTest extends AbstractDatabaseTest {
// Compare
$this
->
assertEquals
(
'Zurich+- Oerlikon+'
,
$result
);
/*
* Check: fillStoreVar['slaveId'] (no explicit fe.slaveId)
*
* slaveId becomes '0', cause there is no Address record 'street="deleteMe"'.
* sqlBefore does nothing, cause there is no Address record 'street="deleteMe"'.
* sqlInsert will create an Address record 'street="deleteMe"'.
* sqlAfter adds '+' after city name.
*/
// fillStoreVar
$feSpecNative
=
[
[
FE_ID
=>
1
,
FE_TYPE
=>
FE_TYPE_TEXT
,
FE_NAME
=>
'firstName'
,
FE_FILL_STORE_VAR
=>
'{{!SELECT id AS slaveId FROM Address WHERE street="deleteMe"}}'
,
FE_SQL_UPDATE
=>
'{{UPDATE Address SET city="Schwamedingen" WHERE id={{slaveId:V}} }}'
,
]
];
$feSpecNative
=
HelperFormElement
::
formElementSetDefault
(
$feSpecNative
,
$formSpec
);
$save
=
new
Save
(
$formSpec
,
[],
$feSpecNative
,
$feSpecNative
);
$save
->
process
();
// Get newly save record
$sql
=
"SELECT city FROM Address WHERE street like 'deleteMe'"
;
$result
=
$this
->
dbArray
[
DB_INDEX_DEFAULT
]
->
sql
(
$sql
,
ROW_IMPLODE_ALL
);
// Compare
$this
->
assertEquals
(
'Schwamedingen'
,
$result
);
}
/**
...
...
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