How to get a field value from an Editor Instance? (PHP)
How to get a field value from an Editor Instance? (PHP)
col45
Posts: 2Questions: 1Answers: 0
Here's what I'm trying to do:
```Field::inst( 'updatecount' )
->set(Field::SET_EDIT)
->setValue( Field::inst( 'updatecount'' )->getValue() + 1 )```
Increment an "update count" on edit.
The getValue isn't returning anything, What function should I be calling to return the posted data?
Short of writing my own parser to loop through the posted array, I'm at a loss?
Due to the structure of the posted data I can't simply get the value via $_POST['data']['updatecount']
data[row_x][updatecount']:10005
Thanks in advance
This discussion has been closed.
Answers
Never mind, I've worked out a way to do it
Sudo code:
if ($_POST)
$key = array_keys($_POST['data']);
$key = $key[0];
var_dump( $_POST['data'][$key]['updatecount']);
hi,
Good to hear you found a solution. It looks like you could probably use the server-side
preEdit
event to do this as well (if theupdatecount
is in the submitted data, that is how I would recommend you do it).A database trigger might be the best solution, or a database function, although the Editor libraries don't currently support db functions I'm afraid.
Allan