So I have been hunting around for the answer to this for some time.
I can add fields to the registration page using the Member Profiles module by following these instructions
http://www.silverstripe.org/community/forums/all-other-modules/show/22082
Which were very helpful.
The problem is I need to add LiteralFields to to the layout and this method does not appear to support that.
The field simply doesn't show up when added to the $fields list.
$fields->push(new LiteralField('Name', 'Content');
No error is generated that I can see and no other oddities occur. The field is simply ignored.
Any idea what I am supposed to do here?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
'Content' is e.g. '<div><h1>Some Content</h1></div>' yeah?
Inspect the html output and see if it shows. Could be some CSS hiding it.
Otherwise try using a different 'Name' - a field added later with the same name will overwrite it.
Thanks for that.
It's nice to know that I am not crazy and at least one other person thinks that this should just work.
Will look into your suggestions and get back.
So the way I resolved this is probably not the ideal way but it does have the advantage that it works.
For whatever reason I am unable to add LiteralFields to the Member Profiles registration form using the method linked in this thread.
But since the module extends Page I was able to interfere with it after the form was created by overriding two templates and introducing a function into Page.php.
First - Override 'MemberProfilePage_register.ss' and in place of $form I placed my own function name $Top.RegistrationForm.
Second - Create new template RegisterForm.ss and copy the code from /framework/templates/includes/Form.ss -- You don't have to do this but since we are customising we might as well get all the controls into our hands
Third - in Page.php create the function RegistrationForm
public function RegistrationForm(){
// grab the form
$alteredRegForm = $this->RegisterForm();
// add the new form template
$alteredRegForm->setTemplate('RegisterForm');
// remove an unwanted field
$alteredRegForm->fields->removeByName('VisibilityNote');
// add a wanted field
$termsfield = new LiteralField("Terms", "Some Text here");
$alteredRegForm->fields->insertBefore($termsfield, 'SomeOtherField');
return $alteredRegForm;
}
That'll do it. Now you have everything you need to customise the registration form in Member Profiles