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

Forms


Go to End


3 Posts   1462 Views

Avatar
Blackdog

Community Member, 156 Posts

27 April 2008 at 11:42pm

I can see what you had in mind with the FormHolder function but I don't think injecting predetermined html into a form without the user specifying it is a good idea.

Prior to SS I had done some sites with Code Igniter which was/is a great framework to use. I found the process of creating forms (which I normally loath) very easy and natural.

Personally I think you should ditch the auto injecting of html and let the developer do a little bit more leg work to customise the form to how they want it. There is also extra html in there that doesn't really need to be there if the developers CSS skills are up to scratch.

By removing the "field" & "$Type" call we could rely on the $extraClass or shorten to $Class which should be more than enough. Also remove $titleBlock and let the user specify this with a new LabelField directly above the field insert or where they need it separating it from the field. Totally scrap the wrapping span as it would not be needed and once again separating $rightTitleBlock & $messageBlock.

Anyway...nothing major. Just a thought.

Avatar
Sean

Forum Moderator, 922 Posts

28 April 2008 at 9:06am

Edited: 28/04/2008 9:08am

If you want to change the way a form renders by default, just take Form.ss from sapphire, put it into your own "Includes" directory for your templates, then change it.

Then, you've got freedom to do things like:

<form $FormAttributes>
	<% control Fields %>
		<div class="fieldHolder" id="$Name">
			<label for="$ID">$Title</label>
			$Field
		</div>
	<% end_control %>

	<div id="actions">
		<% control Actions %>
			$Field
		<% end_control %>
	</div>
</form>

There's also more functions to use in Form, I think you can also select each individual field as well - that way, you don't have to use LabelField and LiteralField in your code, which shouldn't be in there anyway!

Sean

Avatar
Blackdog

Community Member, 156 Posts

28 April 2008 at 10:03am

Thanks for the pointers Sean.

That sounds like a better solution.