always update editor hidden field

always update editor hidden field

crush123crush123 Posts: 417Questions: 126Answers: 18
edited January 2015 in Editor

when i create or edit a table row, I want to update my table with a php session variable to show the userid of the person who last made the change,

i have created a hidden field in my editor, with a default value, and this works fine when i create a new record, but I also want to update the field value on edit, -

i found reference to fields and default values here...https://editor.datatables.net/reference/api/field().def() but i can't work out where to apply it

This question has an accepted answers - jump to answer

Answers

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

    Hi,

    If you happen to be using 1.4 beta, then thee is a better way - use the new setValue() method as it will avoid the client-side needing to send this information, since it is really server-side only data (otherwise you open yourself to a security issue whereby someone could easily modify the sessions ID to make it look like someone else updated content...).

    In 1.4 beta you would use:

    Field::inst( 'myField' )
      ->setValue( $_SESSION['mySessionVar'] );
    

    In 1.3 then using client-side information probably is the cleanest way of doing it. Take a look at the fields.def initialisation option, which should be easier to use that the API method (although they do both basically control the same thing).

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    was running 1.3.3

    just installed the 1.4 beta - and glad I did

    easy to implement and your solution works perfectly.

    Thanks

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

    Good to hear - thanks for the feedback :-).

    I think 1.4 is shaping up nicely imho!

    Allan

This discussion has been closed.