Capitalise Editor New Row Input
Capitalise Editor New Row Input
I have set up Datatables Editor, and it is working great, however I would like to be able to do some simple formatting.
I have a First Name and Surname Columns in my table in columns 2 and 3, and then a postcode Column in Column 10.
When the user opens up the modal form to Add a new row/Record I want to add in some sort of formatting at the point that they click submit, so that it gets sent to the database formatted.
For Columns 2 and 3 I just want each word to have it's first letter capitalized, and then for columns 10 I want all letters to be uppercase.
Can you help me?
I have a First Name and Surname Columns in my table in columns 2 and 3, and then a postcode Column in Column 10.
When the user opens up the modal form to Add a new row/Record I want to add in some sort of formatting at the point that they click submit, so that it gets sent to the database formatted.
For Columns 2 and 3 I just want each word to have it's first letter capitalized, and then for columns 10 I want all letters to be uppercase.
Can you help me?
This discussion has been closed.
Replies
copy this into your /php/lib/Editor/Format.php file:
[code]public static function CapitaliseFirstLetter( $val ) {
return ucwords($val); }[/code]
and then in /php/table.yourtablename.php
replace something like:
[code]
Field::inst( 'FirstName' ),
[/code]
with:
[code]
Field::inst( 'FirstName' )
->getFormatter( 'Format::CapitaliseFirstLetter' )
->setFormatter( 'Format::CapitaliseFirstLetter' ),
[/code]
Anyway, that's probably incredibly obvious to most people, but as a noob it's surprising what simple things you might stuggle with for ages!!
Hope this helps someone
Great to hear you found a solution. This is a fine way of doing it - thanks for sharing your solution with us :-)
Allan