mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
MINOR: added dynamic location for the form field icon - ajshort. MINOR: added custom validation fields to insert form field specific error messages
This commit is contained in:
parent
dde089ccd6
commit
379a5c98d2
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<img class="fieldHandler" src="sapphire/images/drag.gif" alt="<% _t('DRAG', 'Drag to rearrange order of fields') %>" />
|
||||
<% end_if %>
|
||||
|
||||
<img class="icon" src="userforms/images/{$ClassName.LowerCase}.png" alt="$ClassName" title="$singular_name" />
|
||||
<img class="icon" src="$Icon" alt="$ClassName" title="$singular_name" />
|
||||
|
||||
$TitleField
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user