In cases where an Editor field is not to be updated, but its data is displayed for reference, I have "->set(false)" at the server end and "type: display" in the client-side Editor initialization.
Do I actually need both those settings?
No, you don't. But if you want to make sure that the field isn't updated on the server side through front end manipulations I would keep "set (false)" on the server side ("never trust the front end"). The "type: display" is not needed at all. I am never using it. I only disable fields in Editor that mustn't be edited. This also makes sure the user doesn't get confused because they immediately see that the field cannot be edited.
Now I'm getting confused ... Isn't "type: display" something for the data table and not for Editor?!
I found this here in der Editor docs: https://editor.datatables.net/reference/field/
This doesn't have "type: display" but it has a field type "readonly". That might be the right one for you. I've never used it so far ... I only use "disable()".
The display field type is a plug-in. The readonly field uses an actual input element to display the value, while the display plug-in just dumps it into the form as plain text. So they are similar, but a little different.
For example, I use the display plug-in in the sign up / register Editor to split the form into sections.
So in answer to your question @tangerine - yes absolutely keep ->set( false ) as @rf1234 says. If you need the display option - well that one is up to you. If you want to display the value not in an input element in the form, then that's the way to do it.
The background to this is that I'm double-checking some old code, and couldn't remember whether I had previously clarified this.
Thank you, @rf1234 - you helped to clarify my thinking.
And thank you @Allan - having it spelled out like that completes the picture. I have been using the "display" plug-in, as I do want to avoid showing an input element for read-only data.
Answers
No, you don't. But if you want to make sure that the field isn't updated on the server side through front end manipulations I would keep "set (false)" on the server side ("never trust the front end"). The "type: display" is not needed at all. I am never using it. I only disable fields in Editor that mustn't be edited. This also makes sure the user doesn't get confused because they immediately see that the field cannot be edited.
Now I'm getting confused ... Isn't "type: display" something for the data table and not for Editor?!
I found this here in der Editor docs: https://editor.datatables.net/reference/field/
This doesn't have "type: display" but it has a field type "readonly". That might be the right one for you. I've never used it so far ... I only use "disable()".
Now I also found this plug in: https://editor.datatables.net/plug-ins/field-type/editor.display
which you are probably refering to.
@allan: is there a difference between that plug in and the built-in "readonly" field type for Editor?
The
display
field type is a plug-in. Thereadonly
field uses an actualinput
element to display the value, while thedisplay
plug-in just dumps it into the form as plain text. So they are similar, but a little different.For example, I use the
display
plug-in in the sign up / register Editor to split the form into sections.So in answer to your question @tangerine - yes absolutely keep
->set( false )
as @rf1234 says. If you need thedisplay
option - well that one is up to you. If you want to display the value not in an input element in the form, then that's the way to do it.Allan
Welcome to my world....
The background to this is that I'm double-checking some old code, and couldn't remember whether I had previously clarified this.
Thank you, @rf1234 - you helped to clarify my thinking.
And thank you @Allan - having it spelled out like that completes the picture. I have been using the "display" plug-in, as I do want to avoid showing an input element for read-only data.