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.

All other Modules /

Discuss all other Modules here.

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

Change the look of UserDefinedForms


Go to End


9 Posts   3555 Views

Avatar
senica

Community Member, 18 Posts

22 June 2010 at 11:07am

Willr pointed me to using $Form to call my form from the UserDefinedForms module.

Of course, my client wanted some things changed.

I went digging for template to no avail.

I did find in the forum how to call the different elements of the form which would have worked great except no <form> tag and no <submit> button to be found:

I was using this:

<% control Form %>
			<% control Fields %>
				<% if Type == textarea %>
					<div style="overflow:hidden;">						
						<div class="formTitle">$Title &nbsp;&nbsp;$Message</div>
						<div>$Field</div>
					</div>
				<% else %>
					<div style="overflow:hidden;">
						<div class="formError">$Message</div>
						<div style="float:left">$Field</div><div class="formTitle" style="float:left;">$Title</div>
					</div>
				<% end_if %>
				$SubmitButton
			<% end_control %>
			<% end_control %>

$SubmitButton or $Submit does not work.

Is there a template being called when I use $Form that I can just edit? I tried to find what .php file is generating the code but just couldn't find it.

In the end, I just need to change the way the form looks.

Thanks!

Avatar
TotalNet

Community Member, 181 Posts

22 June 2010 at 12:05pm

This can best be achieved with form.css - if you know the layout of the form then you can use the element ID to style each individual form field or otherwise just style them by element type or class.

Avatar
senica

Community Member, 18 Posts

22 June 2010 at 12:10pm

Right, except that in my case, I need the form field Titles to come after the form field, which is a little harder to accomplish with css unless I use the left: attribute and swap them around. It will just get a little harry doing it that way. I'm looking at the API for Form() as it seems to follow that, but still not finding how to display the submit button yet...still loooking.

Avatar
TotalNet

Community Member, 181 Posts

22 June 2010 at 12:19pm

In that case you can always add a "heading" after each form field which adds a label with a class of FormHeading then you can use css to hide the system generated labels.

it's not a pretty solution but means you can avoid editing the core.

Not sure what you're aiming for with the submit button.

Avatar
senica

Community Member, 18 Posts

22 June 2010 at 12:32pm

Well, what I was talking about with the submit button was....if I use the code above, how do I display the submit button and the <form tag?

I'm reading here: http://api.silverstripe.org/2.4/forms/core/Form.html#var$fields and looking at the Variables, but I just don't get it. And when I try stuff it doesn't work, or it may be that UserDefinedForms does not actually extend the Forms class.

:sigh:

using the Code above, I can almost rebuild the entire form, but I cannot figure out how to get the submit button to show...using what variable? ie $Submit and also the form tag? ie <form action="$action" method="$formMethod" $options>

Avatar
TotalNet

Community Member, 181 Posts

22 June 2010 at 12:46pm

Never had that problem with USerDefinedForms, the submit button is always there and the text on it set by the user in the CMS.

If you want complete control over the form layout and don't need/want the user to set it up with the CMS then tutorial 3 deals with writing forms.

You should be able to use UDF to achieve your goals though without needing to touch any code or even template. Just set up the form in the CMS and use css to deal with layout and styling.

Avatar
Willr

Forum Moderator, 5523 Posts

22 June 2010 at 6:46pm

Well you have <% control Fields %> that returns all the fields in the form. But what you want are the 'Actions' like the submit.

<% control Actions %>
..
<% end_control %>

Use the default Form.ss as a guide for what you need to include http://open.silverstripe.org/browser/modules/sapphire/branches/2.4/templates/Includes/Form.ss

Avatar
senica

Community Member, 18 Posts

23 June 2010 at 1:27am

Willr,

Why is that not in the documentation? I mean, in the API, under the Forms object, I saw the Actions() method, but there is no indications of what properties are available when you call it.

Am I just suppose to guess until I get it right?

Or am I just not reading the documentation correctly? http://api.silverstripe.org/2.4/forms/core/Form.html#methodActions

Go to Top