modify displayed field prior to saving

modify displayed field prior to saving

hbanaharishbanaharis Posts: 32Questions: 14Answers: 3

I use a an editField function to modify the contents of a column prior to displaying. How can I modify the contents prior to saving?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Are you using any of our server-side libraries? They all have the concept of “set formatters” (e.g. for PHP) which can be used to transform the value in some way before writing to the database.

    Allan

  • hbanaharishbanaharis Posts: 32Questions: 14Answers: 3

    no but the application relates to addressing a field whose content when received from database is words separated by commas. Currently using render on columns to convert commas to spaces and would like to replace the spaces with commas when writing back to database, i.e:

    raw: apple,pear,orange
    displayed: apple pear orange 
    edit: apple pear banana
    write back to database: apple,pear,banana
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    You can use the preSubmit or ajax.data interfaces in Editor to modify the data that is being sent to the server, which would work in this case with a little regex.

    However, if you have the ability to change the server-side code (?) then that is where I would put the formatter myself.

    Allan

This discussion has been closed.