本文整理汇总了PHP中TextField::setError方法的典型用法代码示例。如果您正苦于以下问题:PHP TextField::setError方法的具体用法?PHP TextField::setError怎么用?PHP TextField::setError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextField
的用法示例。
在下文中一共展示了TextField::setError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMessagesInsideNestedCompositeFields
public function testMessagesInsideNestedCompositeFields()
{
$fieldGroup = new FieldGroup(new CompositeField($textField = new TextField('TestField', 'Test Field'), $emailField = new EmailField('TestEmailField', 'Test Email Field')));
$textField->setError('Test error message', 'warning');
$emailField->setError('Test error message', 'error');
$this->assertEquals('Test error message, Test error message.', $fieldGroup->Message());
$this->assertEquals('warning. error', $fieldGroup->MessageType());
}
示例2: Form
function Form()
{
$array = array();
$array[] = "green";
$array[] = "yellow";
$array[] = "blue";
$array[] = "pink";
$array[] = "orange";
$errorField0 = new TextField($name = "ErrorField0", $title = "Text Field Example 1");
$errorField0->setError("message shown when something is good", "good");
$errorField1 = new TextField($name = "ErrorField1", $title = "Text Field Example 2");
$errorField1->setError("message shown when something is bad", "bad");
$errorField2 = new TextField($name = "ErrorField2", $title = "Text Field Example 3");
$errorField2->setCustomValidationMessage("message shown when something is bad", "bad");
$errorField3 = new TextField($name = "ErrorField3", $title = "Text Field Example 4");
$errorField3->setError("there is an error", "required");
$errorField4 = new TextField($name = "ErrorField4", $title = "Text Field Example 5");
$errorField4->setCustomValidationMessage("custom validation error");
$rightTitle = new TextField($name = "RightTitleField", $title = "Left Title is Default");
$rightTitle->setRightTitle("right title here");
$readonlyField = new ReadOnlyField($name = "ReadOnlyField", $title = "ReadOnlyField");
$readonlyField->setValue("read only value");
$groupedDropdownField = new GroupedDropdownField($name = "dropdown", $title = "Simple Grouped Dropdown", $source = array("primary" => array("1" => "Green", "2" => "Red", "3" => "Blue", "4" => "Orange"), "secondary" => array("11" => "Light Blue", "12" => "Dark Brown", "13" => "Pinkish Red")));
$form = new Form($controller = $this, $name = "TestForm", $fields = new FieldList(new HeaderField($name = "HeaderField1", $title = "Default Header Field"), new LiteralField($name = "LiteralField", "<p>NOTE: All fields up to EmailField are required and should be marked as such</p>"), new TextField($name = "TextField1", $title = "Text Field Example 1"), new TextField($name = "TextField2", $title = "Text Field Example 2"), new TextField($name = "TextField3", $title = "Text Field Example 3"), new TextField($name = "TextField4", $title = ""), new HeaderField($name = "HeaderField2a", $title = "Error Messages", 2), new LiteralField($name = "ErrorExplanations", '<p>Below are some error messages, some of them only show up after you have placed your cursor on the field and not completed it (i.e. a reminder to complete the field)</p>'), $errorField0, $errorField1, $errorField2, $errorField3, $errorField4, new HeaderField($name = "HeaderField2b", $title = "Field with right title", 2), $rightTitle, $textAreaField = new TextareaField($name = "TextareaField", $title = "Textarea Field"), new EmailField("EmailField", "Email address"), new HeaderField($name = "HeaderField2c", $title = "HeaderField Level 2", 2), new DropdownField($name = "DropdownField", $title = "Dropdown Field", array(0 => "-- please select --", 1 => "test AAAA", 2 => "test BBBB")), new OptionsetField($name = "OptionsetField", $title = "Optionset Field", $array), new CheckboxSetField($name = "CheckboxSetField", $title = "Checkbox Set Field", $array), new CurrencyField($name = "CurrencyField", $title = "Bling bling"), new HeaderField($name = "HeaderField3", $title = "Other Fields", 3), new NumericField($name = "NumericField", $title = "Numeric Field "), new DateField($name = "DateField", $title = "Date Field"), new DateField($name = "DateTimeField", $title = "Date and Time Field"), new FileField($name = "FileField", $title = "File Field"), new UploadField($name = "UploadField", $title = "Upload File"), new ConfirmedPasswordField($name = "ConfirmPasswordField", $title = "Password"), new CheckboxField($name = "CheckboxField", $title = "Checkbox Field"), $groupedDropdownField, new HeaderField($name = "HeaderField4", $title = "Read-only Field", 3), $readonlyField), $actions = new FieldList(new FormAction("signup", "Sign up")), $requiredFields = new RequiredFields("TextField1", "TextField2", "TextField3", "ErrorField1", "ErrorField2", "EmailField", "TextField3", "RightTitleField", "CheckboxField", "CheckboxSetField"));
$textAreaField->setColumns(7);
$form->setMessage("warning message", "warning");
return $form;
}