Does anybody know of a way to get the placeholder value of an input field to translate when the system.variables.$language changes? I can get around this issue by using the field labels but would prefer to stick to using placeholders to save on space for mobile devices. Is there some server side code I could use?
Thanks in advance.
Placeholder Translation
Moderators: Jon, Steve, Ian, Dave
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
I guess you are currently applying the placeholder via the custom attributes of the Editor Input tab of Html Element Properties. I can't think of a way of introducing a variable at this point. A possible solution would be to apply the placeholder on the client using jQuery code, then you could add a value programmatically, possible by hiding the field label text with CSS display:none and using this as the text - this would give you the language independence you're looking for. But this seems quite a messy and labour intensive solution.
0 x
-
- Ebase User
- Posts: 67
- Joined: Wed Aug 15, 2012 1:22 pm
-
- Ebase User
- Posts: 94
- Joined: Fri Sep 14, 2007 12:18 pm
- Location: The Netherlands
- Contact:
Re: Placeholder Translation
You could use the Custom Layout option for a panel / page control. Pick up the label from the field and use it as the placeholder. What you would need to do it set the $EDITOR as a variable, then find the input and insert the placeholder using the field label as the value. Hide the field label and you automatically have placeholders in the input that is equivalent to the field label value.
I have tried something similar as a test and it worked. I then found an easier method and so scrapped my prototype. So I know it can be done but don't have an example.
I have tried something similar as a test and it worked. I then found an easier method and so scrapped my prototype. So I know it can be done but don't have an example.
0 x
-
- Ebase User
- Posts: 67
- Joined: Wed Aug 15, 2012 1:22 pm
-
- Ebase User
- Posts: 94
- Joined: Fri Sep 14, 2007 12:18 pm
- Location: The Netherlands
- Contact:
Re: Placeholder Translation
I have just done it myself, here is the code I used:
This is the important bit:
Code: Select all
#set ($MINIMAL_HTML = true)
<section>
#foreach($ctrl in $child_controls)
#if ($ctrl.messagesShowing)
$MESSAGES
#end
#if ($ctrl.showing)
#if ($ctrl.elementType == "Field Control")
<div>
##$FIELD_HEADER
$LABEL
#if ($ctrl.editableRadioOrCheckboxList)
$LIST_HEADER
<ul>
#foreach( $list_item in $list_items )
<li>$LIST_BUTTON $LIST_LABEL</li>
#end
</ul>
$LIST_TRAILER
#else
#set ($placeholder = "input placeholder='" + $ctrl.field.labelText.getText() + "'")
#set ($placeholderEditor = $EDITOR.replace("input", $placeholder))
<div>$placeholderEditor</div>
#end
<div>$HELP</div>
##$FIELD_TRAILER
</div> #else
## Write all controls excluding Field Controls
<div>$CONTROL</div>
#end
#end
#end
</section>
<div></div>
Code: Select all
#set ($placeholder = "input placeholder='" + $ctrl.field.labelText.getText() + "'")
#set ($placeholderEditor = $EDITOR.replace("input", $placeholder))
<div>$placeholderEditor</div>
0 x
Who is online
Users browsing this forum: No registered users and 44 guests