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

fieldByName ......


Go to End
Reply


3 Posts   2591 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.