Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

how can i do with the setter/getter (overloading)


Reply


3 Posts   1636 Views

Avatar
kk

Community Member, 9 Posts

24 June 2008 at 1:29pm

http://doc.silverstripe.com/doku.php?id=datamodel#overloading

class KkitoPage extends Page {
   
   static $db = array(
      "Photos" => "Text"
   );
   
   
   
   
   function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab("Root.Content.Widgets", new TextField("Photos" , "Photos"));
      
      return $fields;
   }
   
   function getPhotos(){
      return "dddfsad";
   }
   
   public function setPhotos($Photos){
//!!!!! what can i do to set the Photos if i want $this->Photos = "prefix".$Photos."suffix"

      //$this->Photos = "kkito";
      //return parent::setPhotos("kkk123123");
      //parent::setPhotos($Photos);
      //$this->obj;
      //$this->obj->Photos = "hahahaha";
   }
   
}

Avatar
kk

Community Member, 9 Posts

24 June 2008 at 1:39pm

and does Widget support the setter/getter method ??

Avatar
kk

Community Member, 9 Posts

24 June 2008 at 7:55pm

//seems it can works , :((((, but i have to assign the fieldname even the method named as the field name
function setPhotos($value){
$this->setField("Photos" , $value);
}