21474 Posts in 5781 Topics by 2620 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1236 Views |
-
Page Type Permissions & TextField Value Not Working

8 May 2009 at 7:32am
A couple things.
I have created a VideoType.php page type. I have added the following to my page class:
public static $can_be_root = false;
public static $allowed_children = 'none';Neither seem to work. I can create this page type with no parent above it, and I can also create any kind of child underneath this page.
Also, I'm trying to populate a TextField with data except nothing is showing up.
$fields->addFieldToTab("Root.Content.Main", new TextField('Author', 'Author', "Testing"), 'Content');
"Testing" does not show up.
I'm using the latest beta version though I'm pretty sure this wasn't working on the stable version I tested the other day.
Am I missing something blatantly obvious, or can somebody confirm this also happens to them?
-
Re: Page Type Permissions & TextField Value Not Working

8 May 2009 at 7:48am Last edited: 8 May 2009 7:50am
Hi LeeUmm
As far as I know, $allowed_children should be an array. You could try $allowed_children = array(); instead.
The $can_be_root directive seems to be ignored indeed... maybe a SilverStripe core developer can shed some light on this?As for your TextField value. It works, as long as the "Author" field isn't a DB field (since its value will be overridden by the value coming from the DB).
If you do:$fields->addFieldToTab(
'Root.Content.Main',
new TextField('NotADBField', 'Author', 'Testing')
);It works just fine. To set a default value for a DB field, use the $defaults array
public static $defaults = array(
'Author' => 'Testing'
); -
Re: Page Type Permissions & TextField Value Not Working

8 May 2009 at 8:02am Last edited: 8 May 2009 8:03am
Thanks for the reply,
I tried changing the $allowed_children to an array and also to $allowed_children = array('none'); with no luck. The docs say just put it like I had in the original topic. Nothing seems to work as I'm able to to create children under them.
As for the populating the text field, thanks for the heads up. To be a bit more specific, I was trying to populate it with the logged in user's name.
I thought this would work? Didn't the blog used to do it like this? Or does? Haven't used it in a while.
function getCMSFields() {
$firstName = Member::CurrentMember() ? Member::currentMember()->FirstName : '';
$lastName = Member::CurrentMember() ? Member::currentMember()->Surname : '';
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextField('Author', 'Author', "$firstName $lastName"), 'Content');
return $fields;
}
| 1236 Views | ||
|
Page:
1
|
Go to Top |


