当前位置: 首页>>代码示例>>PHP>>正文


PHP TextField::setCustomValidationMessage方法代码示例

本文整理汇总了PHP中TextField::setCustomValidationMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP TextField::setCustomValidationMessage方法的具体用法?PHP TextField::setCustomValidationMessage怎么用?PHP TextField::setCustomValidationMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextField的用法示例。


在下文中一共展示了TextField::setCustomValidationMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addShippingAddressFields

 /**
  * Add fields for shipping address and required fields to the validator.
  * 
  * @param Array $fields Array of fields
  * @param OrderFormValidator $validator Checkout form validator
  */
 private function addShippingAddressFields(&$fields, &$validator)
 {
     $firstNameField = new TextField('Shipping[FirstName]', _t('CheckoutPage.FIRSTNAME', "First Name"));
     $firstNameField->addExtraClass('shipping-firstname');
     $firstNameField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_FIRSTNAME', "Please enter a first name."));
     $surnameField = new TextField('Shipping[Surname]', _t('CheckoutPage.SURNAME', "Surname"));
     $surnameField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_SURNAME', "Please enter a surname."));
     $addressField = new TextField('Shipping[Address]', _t('CheckoutPage.ADDRESS1', "Address 1"));
     $addressField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_ADDRESS', "Please enter an address."));
     $cityField = new TextField('Shipping[City]', _t('CheckoutPage.CITY', "City"));
     $cityField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_CITY', "Please enter a city."));
     $countryField = new DropdownField('Shipping[Country]', _t('CheckoutPage.COUNTRY', "Country"), Country::shipping_countries());
     $countryField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_COUNTRY', "Please enter a country."));
     if (!Member::currentUserID() && Geoip::$default_country_code) {
         $countryField->setValue(Geoip::$default_country_code);
     }
     $regions = Region::shipping_regions();
     $regionField = null;
     if (!empty($regions)) {
         $regionField = new RegionField('Shipping[Region]', _t('CheckoutPage.REGION', "Region"));
         $regionField->setCustomValidationMessage(_t('CheckoutPage.PLEASE_ENTER_REGION', "Please enter a country."));
     }
     $sameAddressField = new CheckboxField('ShipToBillingAddress', _t('CheckoutPage.SAME_ADDRESS', "to same address?"));
     $sameAddressField->addExtraClass('shipping-same-address');
     $shippingAddressFields = new CompositeField(new HeaderField(_t('CheckoutPage.SHIPPING_ADDRESS', "Shipping Address"), 3), $sameAddressField, $firstNameField, $surnameField, new TextField('Shipping[Company]', _t('CheckoutPage.COMPANY', "Company")), $addressField, new TextField('Shipping[AddressLine2]', _t('CheckoutPage.ADDRESS2', "Address 2")), $cityField, new TextField('Shipping[PostalCode]', _t('CheckoutPage.POSTAL_CODE', "Postal Code")), new TextField('Shipping[State]', _t('CheckoutPage.STATE', "State")), $countryField);
     if ($regionField) {
         $shippingAddressFields->push($regionField);
     }
     $shippingAddressFields->setID('ShippingAddress');
     $fields['ShippingAddress'][] = $shippingAddressFields;
     $validator->addRequiredField('Shipping[FirstName]');
     $validator->addRequiredField('Shipping[Surname]');
     $validator->addRequiredField('Shipping[Address]');
     $validator->addRequiredField('Shipping[City]');
     $validator->addRequiredField('Shipping[Country]');
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:42,代码来源:CheckoutPage.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:xplore-typography,代码行数:28,代码来源:TypographyTestPage.php


注:本文中的TextField::setCustomValidationMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。