setformatter: return false
setformatter: return false
rf1234
Posts: 3,028Questions: 88Answers: 422
Depending on a condition I want to avoid the update of a field. I.e. I want to do "->set( false )" but based on a condition ... Can I do this with a setFormatter?
Field::inst( 'name' )
->setFormatter( function($val, $data, $opts) {
if ($val = 'whatever') {
return false;
} else {
return $val;
}
}),
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
No - you can't to that with a set formatter I'm afraid. However, you can do it with an event .
Allan
ok, then I will use preCreate and preEdit. Thanks, Allan.
This should work: