Change Casing before updating db
Change Casing before updating db
Hello Everyone, please how do i perform case changing on data submitted before calling ->process( $_POST ). That is to say i want to change all to ucwords() before i insert. Currently this is what am doing :
->fields( ... )
->validator( function ( $editor, $action, $data ) {
if ( $action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT ) {
foreach ( $data['data'] as $pkey => $values ) {
if ( $values === 'currency_name' ) {
$values['currency_name'] = ucwords(strtolower($values['currency_name']));
}
}
}
} )
```->process( $_POST )```
```->json();```
That is, i want to call ucwords() on on the data in currency_name . but its not working,
Please help me,
This question has an accepted answers - jump to answer
Answers
you cannot change any values using a validator. You would need to use a set formatter.
e.g.
Thank you very much @rf1234