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:

Archive /

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

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

Filling in a field automatically

Go to End

3 Posts   2312 Views


Community Member, 34 Posts

7 June 2008 at 2:37am

Hi everyone.

I would like to know if it's possible to fill the Author field of the ArticlePage example (tutorial 2), automatically.
I was thinking about some way to identify the username that is adding the content (something like a $username variable), and fill the DB field with his/her username without typing it (without filling the author field with his/her name manually).

Best regards.


Community Member, 501 Posts

7 June 2008 at 8:18am

Yes, sure this is possible.

Just do something like this in the getCMSFields function:

$member = Member::currentUser();
$fields->addFieldToTab("Root.Content.Main", new TextField("Author", "Author", $member->FirstName . " " . $member->Surname));


Community Member, 34 Posts

9 June 2008 at 10:33pm

Thanks dio5.
That's exactly what I needed.