本文整理汇总了PHP中DropdownField::setCustomValidationMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP DropdownField::setCustomValidationMessage方法的具体用法?PHP DropdownField::setCustomValidationMessage怎么用?PHP DropdownField::setCustomValidationMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DropdownField
的用法示例。
在下文中一共展示了DropdownField::setCustomValidationMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]');
}