Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Placeholder text on UserDefinedForm


Go to End


2 Posts   1606 Views

Avatar
stevanovich

Community Member, 63 Posts

11 March 2015 at 6:30am

Is there a simple way of getting placeholder text on the forms rather than labels. I tried hiding field labels but this didn't work any ideas. SS3.1

Steve

Avatar
priya90

Community Member, 2 Posts

14 March 2015 at 6:51am

You can use this jQuery segment with form id or extra class for the form

$("#idOrclass :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});