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.

Archive /

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

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

Class:FormAction $extraClass problem


Go to End


1895 Views

Avatar
camspiers

Community Member, 5 Posts

14 July 2008 at 2:59pm

Edited: 14/07/2008 3:00pm

Hi,

I'm using version 2.2.2, and I have run into a problem setting a custom class(HTML) using the FormAction Class. This Class gives you the option (using the Class constructor) to set a extra class to output in the generated HTML.

This is implemented by the function Field().

function Field() {
		$titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : '';
		return "<input class=\"action " . $this->extraClass(). "\" id=\"" . $this->id() . "\" type=\"submit\" name=\"{$this->name}\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n";
	}

When I try to use this existing code my extra class is not added, so i have changed it to:

function Field() {
		$titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : '';
		return "<input class=\"action " . $this->extraClass . "\" id=\"" . $this->id() . "\" type=\"submit\" name=\"{$this->name}\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n";
	}

And voila.
Hope this helps someone.
Sorry if the code doesn't format properly, I have not used this forum for submitting code.