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

Reset Form Action


Go to End


3373 Views

Avatar
Dipak

Community Member, 8 Posts

12 February 2009 at 2:07am

Edited: 12/02/2009 2:11am

I have follwing problems

1. After calling ResetFormAction i am unable to clear the validation error message.
2. How can i get the form values in the submission tab of CMS as like UserDefinedForm

Please help me out.
Here is code snippet

function Form() {
return new Form($this, "Form", new FieldSet(

// List your fields here
new TextField("ContactPerson", "Contact Person"),
new EmailField("Email", "Email address"),
new DropdownField("Reason", "Your Reason", array(
"Sales" => "Sales",
"Marketing" => "Marketing")),
new PhoneNumberField( $name = "PhoneNumber",
$title = "Phone Number "
),
new TextareaField( $name = "Remarks",
$title = "Remark",
$rows = 8,
$cols = 3
)

), new FieldSet(

// List the action buttons here
new FormAction("SubmitAction", "Submit"),
new ResetFormAction("ClearAction","Clear")

),
new RequiredFields("ContactPerson","Email","Reason")
);
}

/**
* This function is called when the user submits the form.
*/
function SubmitAction($data, $form) {

// Create a new RemarksDetails object and load the form data into it
$Submissions = new ContactDetails();
$form->saveInto($Submissions);
// Write it to the database. This needs to happen before we add it to a group
$Submissions->write();
$email = new Email();
}