tag input field without a form.

38 views
Skip to first unread message

Mohamed Boucetta

unread,
Oct 11, 2016, 4:05:57 AM10/11/16
to Joomla! General Development
Hello,
I am developing a component.
In this component I would like to add an input tag field (the same you have when you create an article).This input will be associated to search panel. I tried:
$tags= JFormHelper::loadFieldType('Tag', false);
echo $tags->getInput();
with no success.
Any idea?
Regards,
Mohamed

Viper

unread,
Oct 11, 2016, 4:35:50 AM10/11/16
to Joomla! General Development
Remove second parameter.

Mohamed Boucetta

unread,
Oct 11, 2016, 7:44:58 AM10/11/16
to Joomla! General Development
Thanks Viper but it does not work.
To be able to execute $tags->getInput(); I had to change it from protected to public but still it needs a form object in tag.php -> getOptions():
if ($this->form->getName() == 'com_tags.tag')

Any idea?
Regards,

Viper

unread,
Oct 11, 2016, 10:20:45 AM10/11/16
to Joomla! General Development
Try to asking in github repo, because it's looks like a bug. All fields have protected methods, so loadField() doesn't make sense.

Michael Babker

unread,
Oct 11, 2016, 10:34:17 AM10/11/16
to joomla-de...@googlegroups.com
The getInput() method is protected but through the magic getter you can get it through "$tags->input;"

Haven't followed anything else in here, just wanted to comment on that part.

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

Mohamed Boucetta

unread,
Oct 11, 2016, 11:47:06 AM10/11/16
to Joomla! General Development
Indeed $tags->input works as you said.
But it does not fix my issue.
Thanks anyway for the hint :)
To post to this group, send email to joomla-de...@googlegroups.com.

Mohamed Boucetta

unread,
Oct 11, 2016, 11:58:58 AM10/11/16
to Joomla! General Development
I have posted an issue on the github after your suggestion.
Thanks.

Mohamed Boucetta

unread,
Oct 11, 2016, 12:31:17 PM10/11/16
to Joomla! General Development
Here is the reply I have got from github:
Form fields aren't really designed to be used outside of the "normal" form constructs. It is a requirement to have a JForm object set to JFormField instances, so if you're trying to use the field to spit out markup outside of the "normal" workflow you'll need to build up a stub JForm object with the minimal config needed to make this work.

Mohamed Boucetta

unread,
Oct 11, 2016, 6:30:12 PM10/11/16
to Joomla! General Development
I have done as Github has described below and it works!
Thanks guys.
Reply all
Reply to author
Forward
0 new messages