Changeset 64095

Show
Ignore:
Timestamp:
12/10/08 07:46:56 (7 weeks ago)
Author:
ischommer
Message:

ENHANCEMENT Added getters/setters for $tagTopicClass in TagField?
MINOR Documentation for TagField?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • modules/tagfield/trunk/code/TagField.php

    r63923 r64095  
    99 * - Autosuggest functionality (currently JSON only) 
    1010 *  
     11 * Example Datamodel and Instanciation: 
     12 * <code> 
     13 * class Article extends DataObject { 
     14 *      static $many_many = array('Tags'=>'Tag'); 
     15 * } 
     16 * class Tag extends DataObject { 
     17 *      static $db = array('Title'=>'Varchar'); 
     18 *      static $belongs_many_many = array('Articles'=>'Article'); 
     19 * } 
     20 * </code> 
     21 * <code> 
     22 * $form = new Form($this,'Form', 
     23 *      new FieldSet( 
     24 *              new TagField('Tags', 'My Tags', null, 'Article') 
     25 *      ) 
     26 *      new FieldSet() 
     27 * ); 
     28 * $form->loadDataFrom($myArticle); 
     29 * $form->saveInto($myArticle); 
     30 * </code> 
     31 *  
    1132 * @author Ingo Schommer, SilverStripe Ltd. (<firstname>@silverstripe.com) 
    1233 * @package formfields 
     
    5374        protected $customTags; 
    5475         
    55         function __construct($name, $title = null, $value = null, $tagTopicClass) { 
     76        function __construct($name, $title = null, $value = null, $tagTopicClass = null) { 
    5677                $this->tagTopicClass = $tagTopicClass; 
    5778                 
     
    129150        } 
    130151         
     152        /** 
     153         * @param string $class Classname of the DataObject which contains 
     154         * the relation or field for tags. 
     155         */ 
     156        public function setTagTopicClass($class) { 
     157                $this->tagTopicClass = $class; 
     158        } 
     159         
     160        /** 
     161         * @return string Classname 
     162         */ 
     163        public function getTagTopicClass() { 
     164                return $this->tagTopicClass; 
     165        } 
     166         
    131167        protected function saveIntoObjectTags($record) { 
    132168                // HACK We can't save relationship tables without having an ID