10394 Posts in 2203 Topics by 1714 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1112 Views |
-
TagField module - Adding tags to pages

2 September 2010 at 4:24am
Hi,
I'm having a hard time trying to use this module. What I'd like to do is have a form on a page that let's users add tags to pages. I'm not sure I understand how to implement based on the documentation provided in the readme (I am new to SS, so maybe it'd be more obvious if I had more experience?)
I have my Tag.php set up:
class Tag extends DataObject {
static $db = array(
'Title' => 'Varchar(255)'
);
static $belongs_many_many = array(
'SomePages' => 'SomePage'
);
}and SomePage.php:
static $many_many = array(
'Tags'=>'Tag'
);I can't seem to have the form work on submit.
Any help or better documentation?
Thanks!
-
Re: TagField module - Adding tags to pages

3 September 2010 at 6:38am
Okay, that part is figured out. My new question, if anyone is out there...
In order to NOT overwrite the existing tags, I need to use: $form->loadDataFrom($this));
But that's not a great front-end experience, because someone can easily wipe out all the existing tags.
What's the best way to update the new tags? Is there a way to add the data to that field on form submit? I've been poking around but haven't found anything promising.
-
Re: TagField module - Adding tags to pages

3 September 2010 at 8:56am
Got it.
So don't use loadDataFrom. In the save function, get the previous tags, loop through and save them in a string. Then, add that string to the new one that comes in from the form.
Then use:
$newTags = $form->dataFieldByName('Tags');
$newTags->setValue($newTagString);
| 1112 Views | ||
|
Page:
1
|
Go to Top |

