Jump to content

Featured Replies

Posted

I would like to add placeholder attributes to the registration form as members constantly enter the wrong information in the custom fields. I am talking about the greyed out wording in the form boxes that stays there until the user enters their text. Can anyone tell me where to enter the placeholder html code for the custom fields?

 <input type="text" name="fname" placeholder="First name"><br>
  <input type="text" name="lname" placeholder="Last name"><br>

placeholder.png.6de46f302068abf9974d1c733cd37619.png

Thanks

Edited by Genestoy

  • Author

There must be somebody out there that knows how to do this? IPS uses it in the search box

 

Thanks in advance for any help

search.png

Edited by Genestoy

From an HTML perspective it's easy, you just add placeholder="Whatever you want"

The problem is that custom fields use very very central generic HTML templates, so you can't simply edit a template to make it show the value you want. You could probably do something like

{{if $name == 'core_pfield_123'}}
placeholder="First Name"
{{elseif $name == 'core_pfield_456'}}
placeholder="Last Name"
{{endif}}

Or perhaps create a plugin that has a small javascript mixin which does this, but I don't think I'd bother personally.

  • Author

Thanks for the reply Brandon. Where would I place that "example" code you provided? In the registration template? I did check that template before I posted and you are right no easy way to insert the placeholder.

Thanks

No, it's a very central template used by every single text input. It would be core > global > forms > text.

  • Author

Thanks again Brandon, worked perfect!

  • 10 months later...
  • Author

Brandon,

I have just upgraded my test install to 4.5.4 and the above core > global > forms > text you gave me the template is no longer there in 4.5.4? Can you please tell me where I can find the template to insert the placeholder code in?

Thanks again!

Edited by Genestoy

That template should still exist in 4.5.x.

  • Author

Many thanks again Brandon, I feel like an idiot, I was looking in the wrong global!

Recently Browsing 0

  • No registered users viewing this page.