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

Form Questions /

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

Custom login form / problems and best practice


Go to End


2 Posts   5054 Views

Avatar
dkhan

Community Member, 1 Post

9 January 2009 at 3:37am

Edited: 09/01/2009 3:40am

Hello,

I am currently doing my first site with SS and I am quite amazed but I have some minor problems.

I want to have a login form at the left on every page.

For that I added this to my Page.php:

	/**
	 * Shows login Form
	 *
	 * @return Form
	 */
	function LeftLoginForm() {
		return new LeftLoginForm($this, "LeftLoginForm", new FieldSet(
		// Form fields
		new EmailField("Email", "E-Mail"),
		new PasswordField("Password", "Passwort")
		));
	}

I also created a class LeftLogiForm where I override dologin():

	// this function is overloaded on our sublcass (this) to do something different
	public function dologin($data) {
		$this->performLogin($data);
		
		// If this is left out the standard form will show inside content
		// which causes the form handling to break
		Director::redirectBack();
	}

Inside my template I have $LeftLoginForm where the form should go to.
This works fine so far. All System messages are shown inside this form area, etc..

First question: Is this how it is intended to be done, or are there better ways?

Now here is the real problem:

If I click on 'Forgot my password' the form shows up inside the content area.
This form works, but the form on the left is broken because the form action changes to /Security/?executeForm=LeftLoginForm.
If I submit this form I end up with this error message:

user_error(Object::__call() Method 'LeftLoginForm' not found in class 'Security',256)
line 199 of Object.php

Object->__call(LeftLoginForm,Array) 
[...]

What is happening here? What does executeForm do and how can I fix this problem?

Is it possible to show the forgot password form where the login form was?

Thanks in advance

Daniel Khan

Avatar
dospuntocero

Community Member, 54 Posts

5 March 2009 at 12:01am

does your LeftLogiForm.php extends Security.php ?