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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Update Field with another.

Go to End

4 Posts   1288 Views


Community Member, 61 Posts

12 December 2009 at 11:32am

Ok, what I would like to do is automatically update the [Content] field with data from two other CMS fields called [OrphanageName] and [Gender].

This is so that these items will be searchable by the Silverstripe search module.

Any assistance would be appreciated


Community Member, 95 Posts

12 December 2009 at 8:06pm

try adding something like this to your page class:

function onBeforeWrite(){
     $this->Content = $this->OrphanageName . ' ' . $this->Gender;

i didnt test the code, but it should be close... this will always overwrite Content by the way.


Community Member, 61 Posts

12 December 2009 at 11:25pm

Excellent - that works really well.

Do you also know how I can also run a search as an AND rather than an OR??

For example, if I search for Male Mynamar - I still get all females showing from Mynamar.

Any help would be great.



Community Member, 95 Posts

15 December 2009 at 4:18am

not too sure on that one.. you probably will have to extend SearchForm.. theres also an advanced search form class but i've never worked with that, so perhaps it already exists?