Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Archive
SilverStripe Forums » Archive » Filling in a field automatically
Our old forums are still available as a read-only archive.
|
Page:
1
|
Go to End | |
| Author | Topic: Filling in a field automatically | 917 Views |
-
Filling in a field automatically

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.
-
Re: Filling in a field automatically

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)); -
Re: Filling in a field automatically

9 June 2008 at 10:33pm
Thanks dio5.
That's exactly what I needed.
| 917 Views | ||
|
Page:
1
|
Go to Top |
Currently Online: sparkalow, davidm2010, Euphemismus, mattman, PatJnr
Welcome to our latest member: svenmagnus


