Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Form Questions
SilverStripe Forums » Form Questions » Custom form template, error message for server side validation
|
Page:
1
|
Go to End | |
| Author | Topic: Custom form template, error message for server side validation | 1131 Views |
-
Custom form template, error message for server side validation

24 June 2009 at 12:49pm
I have read the following doc http://doc.silverstripe.com/doku.php?id=Form. It works 99% percent the way I wanted. What I would like to know is that, is there more documentation on how to customize the form template. You see, in the example given from above link, only contain two 'text' input filed, what happen if I need dropdown, radio, textarea etc, I would think it needs something like, $dataFieldByName('dropDownName'). I will try them out, but more documentation would be very helpful here.
Second, even though I manage to get this simple form up and running, one thing I found is that if I turn the javascript off, the server side validation seems work all right by not letting script proceed any further, yet, the error message does not show anywhere on the page, some thing is off.
Any advice would be appreciated, I am running out of time.
Thank you.
-
Re: Custom form template, error message for server side validation

24 June 2009 at 1:29pm Last edited: 24 June 2009 1:30pm
To add new form elements you just keep adding them to the fields array:
function MyCustomForm() {
$fields = new FieldSet(
new EmailField("Email"),
new EncryptedField("Password"),
new DropdownField("Foo1", "Bar1"),
new CheckboxField("Foo2", "Bar2"),
);
$actions = new FieldSet(new FormAction("login", "Log in"));
return new Form($this, "MyCustomForm", $fields, $actions);
}This page might be more useful to you: http://doc.silverstripe.com/doku.php?id=recipes:forms
Most likely, you have not created the form action that handles the form response, or your form action does not return anything to the user via a template.
In the above example, you need to have a 'login' method in the controller of the page where the form is located. This login method should return a template, or redirect to another page.
Please supply you code (preferable via http://pastie.org) and I can have a closer look at the issue.
-
Re: Custom form template, error message for server side validation

24 June 2009 at 2:10pm
Hi Hamish
Thank you for your reply. I have posted my code on pastie.org. Here is the link: http://pastie.org/522439
I am aware of these doc you mentioned. I know how to add different type of input into the form, what I am not certain is how to display them in my custom template. Most important, I can't get server side validation error message to be displayed on my custom template.
Thanks again!
-
Re: Custom form template, error message for server side validation

10 December 2009 at 8:29pm
I know it has been a while, but here:
$dataFieldByName(CreditCardNumber)
<span class="message $dataFieldByName(CreditCardNumber).MessageType">$dataFieldByName(CreditCardNumber).Message</span>
| 1131 Views | ||
|
Page:
1
|
Go to Top |


