get field type
get field type
lucianoluna
Posts: 11Questions: 3Answers: 0
in Editor
Hello,
how to get the field type (text, textarea, upload, datetime, ecc.) via editor.field(name).????
I need to convert all text fields to uppercase before save and I'm using event "preSubmit"
editor.fields().forEach(function(elem) {
if field type is text or textarea // **************
editor.field( elem ).set( String(editor.field(elem).val()).toLocaleUpperCase() );
});
This question has an accepted answers - jump to answer
Answers
There's not an API call to get the configuration data, so there would be two options:
make a note of the config that you used when initialising Editor. You could either do this with a constant or a function that returns the config
delve into the Editor internal structures. This isn't really recommended, as that data is private and may change, but it would be consistent for each release (something like this)
Colin
Followed your suggestion n.1 and now can change only text fields to uppcase.
The problem now is I see visually the fields changing correctly to uppercase but aren't saved in the DB in uppercase.
I used the event "preSubmit" to execute this code:
You'd need top use
initSubmit
if you want to change the value of a field before submission. By the timepreSubmit
happens, the field values have already been read.One thing, I'd suggest you actually do this conversion to uppercase on the server-side. It would be trivial to bypass on the client-side which might cause some issues for you?
Allan
yes initSubmit event solve the problem! thank you
Have some hint how to do the conversion to uppercase on server-side?
What are you using on the server-side? If you are using our PHP libraries for example, then you could use a custom set formatter along with PHP's
strtoupper
.Allan
thank you