setting editor default value depending on mode

setting editor default value depending on mode

crush123crush123 Posts: 417Questions: 126Answers: 18

i have an editor form where i want to set the def value of a field to true on create, but false on edit.

the only way i can find to do this is use editor.add() on preOpen() - check the mode and add the field and its mode dependent value here.

seems a bit clunky, and as i have several fields like this I wondered if i can just set the default value depending on editor mode ?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Answer ✓

    If you create a row and it sets the field to true, then edit it, the default won't apply (since it already has a value - true). The preEdit event is the way to do it with a call to field().set() and have it set the field to false.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    sorry, didn't explain too well.

    i am referring to a checkbox which is unbound (ie has no field associated with it), so there is no field value to retrieve

    however, the preEdit event looks like the kind of thing I need

This discussion has been closed.