I just quickly wrote a widget for the JQuery plugin Pines Tags. Pines Tags is a beautiful and easy to use plugin. Even so, this widget is very easy to use.
The Pines Tags plugin is untouched.
Have a look at the Github Repo.
Requirements ¶
Yii 1.1 or above.
Usage ¶
Just extract in your extensions directory and use it like every other widget:
$this->widget('application.extensions.PTags.PTags',array(
'id'=>'die_hard',
'value'=>'action,bruce fucking willis,awesome,explosions,dead terrorists',
'options'=>array(
'editable'=>false,
'remover'=>false
)
));
value are the tags seperated by delimiter(standard: ",") "hardcoded" into the value of the input tag. You can leave it empty and use the tags option if you want to submit an array.
Options are the same as pines tags offers, but without the _ptags__-prefix:
$options=array(
'tags' => array(),
'current_text' => true,
'delimiter' => ",",
'trim_tags' => true,
'show_box' => false,
'input_box' => true,
'remover' => true,
'editable' => true,
'sortable' => false,
);
Resources ¶
- Github Repo
- Pines tags
- Try out a demo
- Yii extension: fancybox (I have stolen the widget skeleton code :D )
Doesn't work.
If the name of the form field of the tags is something like:
MyModel[MyAttribute]
it doesn't work.
On the server "$_POST['MyModel']['MyAttribute']" is empty.
Why?
Solved it.
On "jquery.ptags.js" ptags creates a field named MyModel[MyAttribute]__ptags
this is going to make "MyModel[MyAttribute]" an array. :(
I changed:
input_box.attr("id", input_box.attr("id") + "__ptags"); input_box.attr("name", input_box.attr("name") + "__ptags");
to:
input_box.attr("id", "__ptags_" + input_box.attr("id")); input_box.attr("name", "__ptags_" + input_box.attr("name"));
RE: Solved it.
Hi NCS_One,
so this is an error related to PTags. Please submit your problem/solution as issue/pull request to the PTags git repositories.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.