Placeholder attribute and JForm

1,381 views
Skip to first unread message

Adam Rifat

unread,
Oct 1, 2013, 9:29:10 AM10/1/13
to joomla-...@googlegroups.com
Hi All,

It appears as though the placeholder attribute is not supported by JForm (at least according to this http://docs.joomla.org/Text_form_field_type).

Is that correct?

Just wondering if a custom form field extending JFormFieldText would easily allow a placeholder field. Anyone done this already or know of a tracker pull request etc?

Thanks,

Adam

piotr_cz

unread,
Oct 1, 2013, 11:15:39 AM10/1/13
to joomla-...@googlegroups.com
I remember there was a discussion about extending JFrom, at least with the placeholder attribute.

It is really easy to implement it in own form field like <input /> as you have total control over the rendered HTML:

Simplified

protected function getInput()
{
    $placeholder = $this->element['placeholder'] ? ' placeholder="' . (string) $this->element['placeholder'] . '"' : '';

    return <input type="text" ' . $placeholder . ' name="' . $this->name . '" />';

Achal Aggarwal

unread,
Oct 1, 2013, 11:18:59 AM10/1/13
to joomla-dev-cms
Take a look on http://docs.joomla.org/index.php?title=Text_form_field_type/3.2 . Soon we are going to have this much flexibility in text field and many other fields also.

If you want to test here is the link to my repo

and if just want to take a look go to 


--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms.
For more options, visit https://groups.google.com/groups/opt_out.



--
Achal

Adam Rifat

unread,
Oct 1, 2013, 11:26:12 AM10/1/13
to joomla-...@googlegroups.com
Hi Achal,

Thanks for the links, looks pretty cool. All this will be ready with 3.2?

Thanks,

Adam

Achal Aggarwal

unread,
Oct 1, 2013, 11:40:12 AM10/1/13
to joomla-dev-cms
Hi Adam,

I do hope so. If you are interested in the project you can contribute in testing of it. Here is the link of tracker http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31347 and if you need more test instruction I will post in this thread.

Achal

ssnobben

unread,
Oct 14, 2013, 6:00:39 AM10/14/13
to joomla-...@googlegroups.com
I wonder if it could be used so the following scenario can work also with a group selector.

User choose user group A and then the fields a,b,c,e, f, g only shows up.

User choose user group B and then the fields a,b,c, f, g, h  only shows up.

So depending on your choice of user group you get some reg fields automatic populated for just that user group.


Would that possible to add to this development?

piotr_cz

unread,
Oct 14, 2013, 8:52:42 AM10/14/13
to joomla-...@googlegroups.com
ssnobben > I can't track back the Pull request, but check recent changes to Global configuration xml file, especially the `showon` attribute with FTP settings:

Fields for FTP settings are supposed to show up only when FTP is enabled.

piotr_cz

unread,
Oct 21, 2013, 12:29:11 PM10/21/13
to joomla-...@googlegroups.com
Hi, I found the related PR: https://github.com/joomla/joomla-cms/pull/1842

If you want to use the input placeholder attribute, use 'hint':
<field
    name="test"
    type="textarea"
    hint="Type something here"
/>

It the placeholder is translatable, use attribute translateHint="true".


On Tuesday, October 1, 2013 3:29:10 PM UTC+2, Adam Rifat wrote:

Adam Rifat

unread,
Oct 22, 2013, 5:02:20 AM10/22/13
to joomla-...@googlegroups.com
I wonder why is there a separate attribute for translate hint? Isn't it easier if the string just gets passed through JText::_

I mean I don't have to specify whether I want the label or description translated at the moment. If I pass in a language string it gets translated, if not it doesn't.

Achal Aggarwal

unread,
Oct 22, 2013, 6:42:24 AM10/22/13
to joomla-dev-cms
Hi Adam,

See https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/form/field.php#L470 translateHint has default value of true and if you want to stop translating hint (or description or label) then you can just add translateHint="off" or translateHint="false" or  translateHint="0".

So the only reason I can think of using translateHint is the case when we want don't want to translate whatever it put down in hint attribute.


--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-cm...@googlegroups.com.
To post to this group, send an email to joomla-...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-cms.
For more options, visit https://groups.google.com/groups/opt_out.



--
Achal

Adam Rifat

unread,
Oct 23, 2013, 7:54:27 AM10/23/13
to joomla-...@googlegroups.com
I see, so it's a way to switch translations off, if for some reason you didn't want the text translated.

Anyway, looking forward to the new fields so I can use the placeholders. Thanks!
Reply all
Reply to author
Forward
0 new messages