Multiple setFormatter
Multiple setFormatter
Is it possible to use multiple setFormatter for a same field ?
Exemple / more informations :
This alone work :
Field::inst( 'XXXXXX' )
->setFormatter( function ( $val, $data ) {
return strtoupper( $val );
} )
This alone also work :
Field::inst( 'XXXXXX' )
->setFormatter( Format::ifEmpty( null ) ),
but when i try to use both at the same time it doesn't work (only the last one declared work)
Field::inst( 'XXXXXX' )
->setFormatter( function ( $val, $data ) {
return strtoupper( $val );
} )
->setFormatter( Format::ifEmpty( null ) )
} ),
Thank in advance for your answer
This question has an accepted answers - jump to answer
Answers
No sorry. It is a single scalar value rather than an array which is iterated over.
However! As you've seen you can define your own functions, so what to do is just combine the two actions together into a single function:
Allan
That work perfectly,
thank you