Support #4236
How to use fields.[db_field].postProcessing
| Status: | Closed | Start date: | 2009-08-12 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Reinhard Führicht | % Done: | 100% |
|
| Category: | Finisher | |||
| Target version: | - | |||
| Votes: | 0 |
Description
So, I'm finally trying to write my form values to an extra database table, and once again I'm getting stuck :(
The mapping of the form fields to the database fields works fine in general, but I don't get any return values from the userFuncs I use for postProcessing some of the fields.
This is what I'm doing:
finishers {
1 {
class = Tx_Formhandler_Finisher_DB
config {
table = tx_comvosextformhandler_log
key = uid
fields {
c_1.postProcessing = USER
#c_1.postProcessing.value = register
c_1.postProcessing.userFunc = user_formhandlerhelper->postProcessC1
c_1.mapping = register
}
}
}
}
(I tried adding the commented line after looking at the code of the finisher class, but it didn't help.)
I seem to get no return value from this userFunc, the database fields remain empty. I'm not sure if it even gets called at all. However, I'm resonably certain that the userFunc and its class are implemented correctly, since I've been using several other userFuncs in the same class with no problems. Here's my test function:
class user_formhandlerhelper {
function postProcessC1() {
return '123';
}
}
Setting debug to 1 doesn't produce any errors, output was this:
(...)
Calling finisher "Tx_Formhandler_Finisher_DB"
Data gets stored!
(...)
What I'm actually trying to do here is to take an array of orders (from checkboxes) and save their prices to seperate database columns.
I really hope I'm once more making just a small mistake here, but I just can't identify it...
History
Updated by Reinhard Führicht almost 4 years ago
It seems that I made a copy/paste mistake in the code.
Apparently the userFunc defined in preProcessing will be called for postProcessing too.
I will fix this tomorrow morning. Then the postProcessing should work fine.
Updated by Reinhard Führicht almost 4 years ago
- Category set to Finisher
- Assignee set to Reinhard Führicht
Ok, I have committed it today, but without testing.
I just fixed the copy/paste mistakes.
Please tell me, if it works ok now. I will be able to test it myself tomorrow morning.
Updated by Reinhard Führicht almost 4 years ago
Another thing because I just saw it:
class user_formhandlerhelper {
function postProcessC1() {
return '123';
}
}
The value of the form field is passed to the userFunc by Formhandler. In order to access it, you can use $conf['value'] in your function:
class user_formhandlerhelper {
function postProcessC1($content = '', $conf = array()) {
$value = $conf['value'];
... process value ...
return $value;
}
}
PostProcessing only changes the value of the field for the INSERT query in Finisher_DB. It will not change the value of the field for further use in other Finishers!
Updated by Veronica almost 4 years ago
Reinhard Führicht wrote:
Ok, I have committed it today, but without testing. I just fixed the copy/paste mistakes. Please tell me, if it works ok now. I will be able to test it myself tomorrow morning.
I missed your reply by a few minutes and now I'm already back at home, but I'll check this first thing tomorrow morning.
Thanks for the quick support!
Updated by Veronica almost 4 years ago
Veronica wrote:
Reinhard Führicht wrote:
Ok, I have committed it today, but without testing. I just fixed the copy/paste mistakes. Please tell me, if it works ok now. I will be able to test it myself tomorrow morning.
I missed your reply by a few minutes and now I'm already back at home, but I'll check this first thing tomorrow morning.
Thanks for the quick support!
Okay, I just checked it, and it works now. Thank you!
Updated by Reinhard Führicht almost 4 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100