Capitalise Editor New Row Input

Capitalise Editor New Row Input

bensdbbensdb Posts: 30Questions: 4Answers: 0
edited April 2014 in Editor
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?

Replies

  • bensdbbensdb Posts: 30Questions: 4Answers: 0
    Ok I have now figured this out
  • bensdbbensdb Posts: 30Questions: 4Answers: 0
    Just incase anyone is has the same problem:

    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
  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    Hi,

    Great to hear you found a solution. This is a fine way of doing it - thanks for sharing your solution with us :-)

    Allan
This discussion has been closed.