Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » fieldByName ......

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: 1963 Views
  • carlossg
    Avatar
    Community Member
    13 Posts

    fieldByName ...... Link to this post

    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.

  • carlossg
    Avatar
    Community Member
    13 Posts

    Re: fieldByName ...... Link to this post

    got the answer.

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

    That leads me to a question?

    What does fieldByName() retrieve?.

    Thanks.

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: fieldByName ...... Link to this post

    fieldByName() returns a field at the top level.

    dataFieldByName() checks in tabs as well.

    1963 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.