Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

datatables.js Editor – Replace character in string on create/update

Using datatables.js Editor, I want to replace a character, a semicolon, with &#x3b; when data is submitted to the database.

I am told that this can be done with the setFormatter function:

https://editor.datatables.net/manual/php/formatters

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How would I do this? Example would be great.

NOTE: The editor is the PHP API version

>Solution :

The documentation you linked to is for the PHP API, but your question is not tagged with PHP. Assuming you are indeed using PHP you can use str_replace to replace one character with another.

Field::inst( 'your_field_name' )->setFormatter( function ( $fieldValue, $rowData ) {
    return str_replace(';','&#x3b;',$fieldValue); //replace semicolon with html escape sequence
} )

Change your_field_name as needed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading