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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

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


Go to End


3 Posts   2444 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);
}