Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » how can i do with the setter/getter (overloading)

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

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

Page: 1
Go to End
Author Topic: 1598 Views
  • kk
    Avatar
    Community Member
    9 Posts

    how can i do with the setter/getter (overloading) Link to this post

    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";
       }
       
    }

  • kk
    Avatar
    Community Member
    9 Posts

    Re: how can i do with the setter/getter (overloading) Link to this post

    and does Widget support the setter/getter method ??

  • kk
    Avatar
    Community Member
    9 Posts

    Re: how can i do with the setter/getter (overloading) Link to this post

    //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);
    }

    1598 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.