diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 09baaac..ee5e991 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -274,10 +274,15 @@ class UserDefinedForm_Controller extends Page_Controller { $required = array(); if(!$this->SubmitButtonText) { - $this->SubmitButtonText = 'Submit'; + $this->SubmitButtonText = _t('UserDefinedForm.SUBMITBUTTON', 'Submit'); } foreach($this->Fields() as $field) { - $fields->push($field->getFormField()); + $fieldToAdd = $field->getFormField(); + if($field->CustomErrorMessage) { + $fieldToAdd->setCustomValidationMessage($field->CustomErrorMessage); + } + + $fields->push($fieldToAdd); if($field->Required) { $required[] = $field->Name; } @@ -295,7 +300,7 @@ class UserDefinedForm_Controller extends Page_Controller { new FormAction("process", $this->SubmitButtonText) ); - // Do we want to add a clear form. Should do this via js + // Do we want to add a clear form. if($this->ShowClearButton) { $actions->push(new ResetFormAction("clearForm")); } @@ -539,10 +544,10 @@ class UserDefinedForm_SubmittedFormEmailToSubmitter extends Email { protected $subject = 'Submission of form'; protected $data; - function __construct($values) { - $this->subject = _t('UserDefinedForm_SubmittedFormEmail.EMAILSUBJECT', 'Submission of form'); - parent::__construct(); + function __construct($values = null) { + $this->subject = _t('UserDefinedForm_SubmittedFormEmail.EMAILSUBJECT', 'Submission of form'); + parent::__construct(); $this->data = $values; } diff --git a/code/editor/EditableFormField.php b/code/editor/EditableFormField.php index 9cf6f22..1c053c0 100755 --- a/code/editor/EditableFormField.php +++ b/code/editor/EditableFormField.php @@ -15,9 +15,10 @@ class EditableFormField extends DataObject { "Default" => "Varchar", "Sort" => "Int", "Required" => "Boolean", - "CanDelete" => "Boolean", - "CustomParameter" => "Varchar", - "OptionallyDisplay" => "Boolean" + "CanDelete" => "Boolean", + "CustomParameter" => "Varchar", + "OptionallyDisplay" => "Boolean", + "CustomErrorMessage" => "Varchar(255)" ); static $defaults = array( @@ -70,6 +71,15 @@ class EditableFormField extends DataObject { return $this->class; } + /** + * Get the path to the icon for this field type, relative to the site root. + * + * @return string + */ + public function Icon() { + return 'userforms/images/' . strtolower($this->class) . '.png'; + } + /** * Return whether or not this field has addable options * such as a dropdown field or radio set @@ -129,6 +139,7 @@ class EditableFormField extends DataObject { $this->Required = !empty($data['Required']) ? 1 : 0; $this->CanDelete = (isset($data['CanDelete']) && !$data['CanDelete']) ? 0 : 1; $this->Name = $this->class.$this->ID; + $this->CustomErrorMessage = (isset($data['CustomErrorMessage'])) ? $data['CustomErrorMessage'] : ""; $this->write(); } @@ -159,6 +170,9 @@ class EditableFormField extends DataObject { // support for optionally display field // $extraOptions->push(new CheckboxField($baseName ."[OptionallyDisplay]", _t('EditableFormField.OPTIONALLYDISPLAY', 'Optionally Display Field'), $this->OptionallyDisplay)); + // support for custom error messaging + $extraOptions->push(new TextField($baseName.'[CustomErrorMessage]', _t('EditableFormField.CUSTOMERROR','Custom Error Message'), $this->CustomErrorMessage)); + return $extraOptions; } diff --git a/templates/EditableFormField.ss b/templates/EditableFormField.ss index ca6030d..fdb4736 100755 --- a/templates/EditableFormField.ss +++ b/templates/EditableFormField.ss @@ -6,7 +6,7 @@ <% _t('DRAG', 'Drag to rearrange order of fields') %> <% end_if %> - $ClassName + $ClassName $TitleField