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

fieldByName ......


Go to End


3 Posts   3966 Views

Avatar
carlossg

Community Member, 13 Posts

5 August 2008 at 7:23am

Hi all.
Just trying to change label in "Root.Content.Main.Title"

class DepartmentPage extends Page {
   function getCMSFields() {
      $fields = parent::getCMSFields();
      
      $gg = $fields->fieldByName("Root.Content.Main.Title"); // same error with filedByName("Title").
      $gg->setTitle("My new Title");

I get this error
Fatal error: Call to a member function setTitle() on a non-object in /public_html/silverstripe/tutorial/code/DepartmentPage.php on line 27

Thanks in advanced.

Avatar
carlossg

Community Member, 13 Posts

5 August 2008 at 7:27am

Edited: 05/08/2008 7:28am

got the answer.

use dataFieldByName("Title")instead fieldByName("Title").

That leads me to a question?

What does fieldByName() retrieve?.

Thanks.

Avatar
(deleted)

Community Member, 473 Posts

5 August 2008 at 7:31am

fieldByName() returns a field at the top level.

dataFieldByName() checks in tabs as well.