-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathplaceholder_input_3.6.js
36 lines (31 loc) · 1.39 KB
/
placeholder_input_3.6.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// this script will allow you to add placeholder attributes to input text and textarea elements
// in addition to Fields alias it can help user to understand field usage
// configure using tabPlaceholder variable :
// list layer's fields on which a placeholder attributes will be set
/*
{ "<layer slug>" (via dom html or project file) : {
'<field dom id 1>' ( jforms_view_edition_<field_name>) : "<Placeholder value (will be display on empty field)>" ,
'<field dom id 2>' : "<placeholder 2>" ,
...
}}
*/
lizMap.events.on({
lizmapeditionformdisplayed: function(e) {
// example with a pizzeria layer with fields name and description
// must be changed
var tabPlaceholder = { 'pizzeria_f97c3105_7b75_45d5_ac1f_b953d1c1d6f8' : {
'jforms_view_edition_name' : "Example : la dolce vita",
"jforms_view_edition_description" : "Fill free to add your description : opening hours, parking, ..."
}
} ;
for( var i in tabPlaceholder ) {
// matching layerID
if (e.layerId === i) {
let fields = tabPlaceholder[i];
for( var inputElement_id in fields) {
document.getElementById(inputElement_id).setAttribute('placeholder',fields[inputElement_id])
}
}
}
}
});