From a9df2459e99dd82fa9bc6de132e555d18ea4b9ab Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 10:48:44 +0100 Subject: [PATCH 01/15] Add {{depend}} to telephone line in default address text template --- app/code/Magento/Customer/etc/config.xml | 2 +- .../Magento/Framework/Filter/Test/Unit/TemplateTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/etc/config.xml b/app/code/Magento/Customer/etc/config.xml index ccee6914e4ea0..bc7e0f0741393 100644 --- a/app/code/Magento/Customer/etc/config.xml +++ b/app/code/Magento/Customer/etc/config.xml @@ -65,7 +65,7 @@ {{depend street4}}{{var street4}}{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}} {{var country}} -T: {{var telephone}} +{{depend telephone}}T: {{var telephone}}{{/depend}} {{depend fax}}F: {{var fax}}{{/depend}} {{depend vat_id}}VAT: {{var vat_id}}{{/depend}} {{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}}, {{var street}}, {{var city}}, {{var region}} {{var postcode}}, {{var country}} diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php index 49349e2d4bb1d..720433138053b 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php @@ -43,7 +43,7 @@ public function testFilter() {{depend street4}}{{var street4}}{{/depend}} {{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}} {{var country}} -T: {{var telephone}} +{{depend telephone}}T: {{var telephone}}{{/depend}} {{depend fax}}F: {{var fax}}{{/depend}} {{depend vat_id}}VAT: {{var vat_id}}{{/depend}} TEMPLATE; From bad78190184db7b16d2b4a43869bb20835ac6598 Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 11:30:33 +0100 Subject: [PATCH 02/15] Add new configuration field for the telephone field --- app/code/Magento/Customer/etc/adminhtml/system.xml | 5 +++++ app/code/Magento/Customer/etc/config.xml | 1 + app/code/Magento/Customer/i18n/en_US.csv | 1 + 3 files changed, 7 insertions(+) diff --git a/app/code/Magento/Customer/etc/adminhtml/system.xml b/app/code/Magento/Customer/etc/adminhtml/system.xml index 66c54016fc227..461f38e2b8b39 100644 --- a/app/code/Magento/Customer/etc/adminhtml/system.xml +++ b/app/code/Magento/Customer/etc/adminhtml/system.xml @@ -232,6 +232,11 @@ Magento\Config\Model\Config\Source\Nooptreq Magento\Customer\Model\Config\Backend\Show\Customer + + + Magento\Config\Model\Config\Source\Nooptreq + Magento\Customer\Model\Config\Backend\Show\Customer + diff --git a/app/code/Magento/Customer/etc/config.xml b/app/code/Magento/Customer/etc/config.xml index bc7e0f0741393..0bab687982a15 100644 --- a/app/code/Magento/Customer/etc/config.xml +++ b/app/code/Magento/Customer/etc/config.xml @@ -51,6 +51,7 @@ + req 1 diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index ab7df0a3aa514..8847f6b604ec4 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -474,6 +474,7 @@ Password:,Password: "Show Date of Birth","Show Date of Birth" "Show Tax/VAT Number","Show Tax/VAT Number" "Show Gender","Show Gender" +"Show Telephone","Show Telephone" "Login Options","Login Options" "Redirect Customer to Account Dashboard after Logging in","Redirect Customer to Account Dashboard after Logging in" "Customer will stay on the current page if ""No"" is selected.","Customer will stay on the current page if ""No"" is selected." From 5b32a012772590d59350ddb1434b580120d48e2c Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 12:20:37 +0100 Subject: [PATCH 03/15] Fix backend model for config field "show telephone" --- .../Model/Config/Backend/Show/AddressOnly.php | 26 +++++++++++++++++++ .../Magento/Customer/etc/adminhtml/system.xml | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Customer/Model/Config/Backend/Show/AddressOnly.php diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/AddressOnly.php b/app/code/Magento/Customer/Model/Config/Backend/Show/AddressOnly.php new file mode 100644 index 0000000000000..ed35fb436940b --- /dev/null +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/AddressOnly.php @@ -0,0 +1,26 @@ + + */ +class AddressOnly extends Customer +{ + /** + * Retrieve attribute objects + * + * @return AbstractAttribute[] + */ + protected function _getAttributeObjects() + { + return [$this->_eavConfig->getAttribute('customer_address', $this->_getAttributeCode())]; + } +} diff --git a/app/code/Magento/Customer/etc/adminhtml/system.xml b/app/code/Magento/Customer/etc/adminhtml/system.xml index 461f38e2b8b39..476d07620f7f9 100644 --- a/app/code/Magento/Customer/etc/adminhtml/system.xml +++ b/app/code/Magento/Customer/etc/adminhtml/system.xml @@ -235,7 +235,7 @@ Magento\Config\Model\Config\Source\Nooptreq - Magento\Customer\Model\Config\Backend\Show\Customer + Magento\Customer\Model\Config\Backend\Show\AddressOnly From 93d23f261e386b02fa51a8e31ff4a1ee47cba555 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sat, 11 Feb 2017 14:06:27 +0100 Subject: [PATCH 04/15] display the telephone field conditionally dependant upon the configuration --- .../Customer/Block/Widget/Telephone.php | 191 ++++++++++++++++++ .../frontend/templates/form/register.phtml | 13 +- .../frontend/templates/widget/telephone.phtml | 17 ++ 3 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 app/code/Magento/Customer/Block/Widget/Telephone.php create mode 100644 app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml diff --git a/app/code/Magento/Customer/Block/Widget/Telephone.php b/app/code/Magento/Customer/Block/Widget/Telephone.php new file mode 100644 index 0000000000000..49781f39d7c7b --- /dev/null +++ b/app/code/Magento/Customer/Block/Widget/Telephone.php @@ -0,0 +1,191 @@ +options = $options; + parent::__construct($context, $addressHelper, $customerMetadata, $data); + $this->addressMetadata = $addressMetadata; + $this->_isScopePrivate = true; + } + + /** + * @return void + */ + public function _construct() + { + parent::_construct(); + + // default template location + $this->setTemplate('widget/telephone.phtml'); + } + + /** + * Can show config value + * + * @param string $key + * + * @return bool + */ + protected function _showConfig($key) + { + return (bool)$this->getConfig($key); + } + + /** + * Can show prefix + * + * @return bool + */ + public function showTelephone() + { + return $this->_isAttributeVisible(self::ATTRIBUTE_CODE); + } + + /** + * {@inheritdoc} + */ + protected function _getAttribute($attributeCode) + { + if ($this->getForceUseCustomerAttributes() || $this->getObject() instanceof CustomerInterface) { + return parent::_getAttribute($attributeCode); + } + + try { + $attribute = $this->addressMetadata->getAttributeMetadata($attributeCode); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + return null; + } + + if ($this->getForceUseCustomerRequiredAttributes() && $attribute && !$attribute->isRequired()) { + $customerAttribute = parent::_getAttribute($attributeCode); + if ($customerAttribute && $customerAttribute->isRequired()) { + $attribute = $customerAttribute; + } + } + + return $attribute; + } + + /** + * Retrieve store attribute label + * + * @param string $attributeCode + * + * @return string + */ + public function getStoreLabel($attributeCode) + { + $attribute = $this->_getAttribute($attributeCode); + return $attribute ? __($attribute->getStoreLabel()) : ''; + } + + /** + * Get string with frontend validation classes for attribute + * + * @param string $attributeCode + * + * @return string + */ + public function getAttributeValidationClass($attributeCode) + { + return $this->_addressHelper->getAttributeValidationClass($attributeCode); + } + + /** + * @param string $attributeCode + * + * @return bool + */ + private function _isAttributeRequired($attributeCode) + { + $attributeMetadata = $this->_getAttribute($attributeCode); + return $attributeMetadata ? (bool)$attributeMetadata->isRequired() : false; + } + + /** + * @param string $attributeCode + * + * @return bool + */ + private function _isAttributeVisible($attributeCode) + { + $attributeMetadata = $this->_getAttribute($attributeCode); + return $attributeMetadata ? (bool)$attributeMetadata->isVisible() : false; + } + + /** + * Check if telephone attribute enabled in system + * + * @return bool + */ + public function isEnabled() + { + return $this->_getAttribute(self::ATTRIBUTE_CODE) ? (bool)$this->_getAttribute(self::ATTRIBUTE_CODE)->isVisible( + ) : false; + } + + /** + * Check if telephone attribute marked as required + * + * @return bool + */ + public function isRequired() + { + return $this->_getAttribute(self::ATTRIBUTE_CODE) ? (bool)$this->_getAttribute(self::ATTRIBUTE_CODE) + ->isRequired() : false; + } +} diff --git a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml index 54206ea5fdaf7..6f08bf4a16d8c 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml @@ -51,12 +51,11 @@ -
- -
- -
-
+ + getLayout()->createBlock('Magento\Customer\Block\Widget\Telephone') ?> + isEnabled()): ?> + setTelephone($block->getFormData()->getTelephone())->toHtml() ?> + helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?> @@ -176,7 +175,7 @@ require([ var dataForm = $('#form-validate'); var ignore = isEnabled() ? '\'input[id$="full"]\'' : 'null'; ?>; - + dataForm.mage('validation', { isEnabled()): ?> errorPlacement: function(error, element) { diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml new file mode 100644 index 0000000000000..5b995e6f647ee --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml @@ -0,0 +1,17 @@ + + +
+ +
+ +
+
From 1b66bb07b97070991d99a752ff4828d05d154202 Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 14:43:33 +0100 Subject: [PATCH 05/15] Update validation of customer and quote address for the case of "telephone" not being a required field --- .../Customer/Model/Address/AbstractAddress.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index a34691143dbe1..19896ddb66599 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -579,9 +579,11 @@ public function validate() $errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']); } - if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) { - $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']); + if ($this->isTelephoneFieldRequired()) { + if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) { + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']); + } } $_havingOptionalZip = $this->_directoryData->getCountriesWithOptionalZip(); @@ -640,4 +642,12 @@ public function unsRegion() { return $this->unsetData("region"); } + + /** + * @return bool + */ + protected function isTelephoneFieldRequired() + { + return ($this->_eavConfig->getAttribute('customer_address', 'telephone')->getIsRequired()); + } } From d4bd82b9ca0990c397f51ccce888ada72bae9949 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sat, 11 Feb 2017 14:54:58 +0100 Subject: [PATCH 06/15] display the telephone field in the address edit form conditionally --- .../frontend/templates/address/edit.phtml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml b/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml index 94b545d1eb4a4..ab8ea6fd43533 100644 --- a/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml @@ -8,6 +8,7 @@ /** @var \Magento\Customer\Block\Address\Edit $block */ ?> +getLayout()->createBlock('Magento\Customer\Block\Widget\Telephone') ?>
-
- -
- -
-
+ + isEnabled()): ?> + setTelephone($block->getAddress()->getTelephone())->toHtml() ?> + +
From 6540ef8b984c1d8dfc5455a8123e966353da91a9 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sat, 11 Feb 2017 14:55:42 +0100 Subject: [PATCH 07/15] Added system configuration for toggling display of company and fax fields --- app/code/Magento/Customer/etc/adminhtml/system.xml | 10 ++++++++++ app/code/Magento/Customer/etc/config.xml | 2 ++ app/code/Magento/Customer/i18n/en_US.csv | 2 ++ 3 files changed, 14 insertions(+) diff --git a/app/code/Magento/Customer/etc/adminhtml/system.xml b/app/code/Magento/Customer/etc/adminhtml/system.xml index 476d07620f7f9..bae7e0ab01db3 100644 --- a/app/code/Magento/Customer/etc/adminhtml/system.xml +++ b/app/code/Magento/Customer/etc/adminhtml/system.xml @@ -237,6 +237,16 @@ Magento\Config\Model\Config\Source\Nooptreq Magento\Customer\Model\Config\Backend\Show\AddressOnly + + + Magento\Config\Model\Config\Source\Nooptreq + Magento\Customer\Model\Config\Backend\Show\AddressOnly + + + + Magento\Config\Model\Config\Source\Nooptreq + Magento\Customer\Model\Config\Backend\Show\AddressOnly + diff --git a/app/code/Magento/Customer/etc/config.xml b/app/code/Magento/Customer/etc/config.xml index 0bab687982a15..1a9c2eddfd2d4 100644 --- a/app/code/Magento/Customer/etc/config.xml +++ b/app/code/Magento/Customer/etc/config.xml @@ -52,6 +52,8 @@ req + opt + 1 diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index 8847f6b604ec4..ce6c117a107b8 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -475,6 +475,8 @@ Password:,Password: "Show Tax/VAT Number","Show Tax/VAT Number" "Show Gender","Show Gender" "Show Telephone","Show Telephone" +"Show Company","Show Company" +"Show Fax","Show Fax" "Login Options","Login Options" "Redirect Customer to Account Dashboard after Logging in","Redirect Customer to Account Dashboard after Logging in" "Customer will stay on the current page if ""No"" is selected.","Customer will stay on the current page if ""No"" is selected." From 94f0265472e137aca2cd440fe6941d4abec77a83 Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 15:09:55 +0100 Subject: [PATCH 08/15] Update validation of order address for the case of "telephone" not being a required field --- .../Model/Address/AbstractAddress.php | 4 +-- .../Sales/Model/Order/Address/Validator.php | 30 ++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 19896ddb66599..207a6455655fa 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -579,7 +579,7 @@ public function validate() $errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']); } - if ($this->isTelephoneFieldRequired()) { + if ($this->isTelephoneRequired()) { if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) { $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']); @@ -646,7 +646,7 @@ public function unsRegion() /** * @return bool */ - protected function isTelephoneFieldRequired() + protected function isTelephoneRequired() { return ($this->_eavConfig->getAttribute('customer_address', 'telephone')->getIsRequired()); } diff --git a/app/code/Magento/Sales/Model/Order/Address/Validator.php b/app/code/Magento/Sales/Model/Order/Address/Validator.php index f46d8c4979a1c..902e7482e3a77 100644 --- a/app/code/Magento/Sales/Model/Order/Address/Validator.php +++ b/app/code/Magento/Sales/Model/Order/Address/Validator.php @@ -5,6 +5,7 @@ */ namespace Magento\Sales\Model\Order\Address; +use Magento\Eav\Model\Config as EavConfig; use Magento\Sales\Model\Order\Address; use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Directory\Model\CountryFactory; @@ -24,7 +25,6 @@ class Validator 'street' => 'Street', 'city' => 'City', 'email' => 'Email', - 'telephone' => 'Phone Number', 'country_id' => 'Country', 'firstname' => 'First Name', 'address_type' => 'Address Type', @@ -40,16 +40,27 @@ class Validator */ protected $countryFactory; + /** + * @var EavConfig + */ + protected $eavConfig; + /** * @param DirectoryHelper $directoryHelper * @param CountryFactory $countryFactory */ public function __construct( DirectoryHelper $directoryHelper, - CountryFactory $countryFactory + CountryFactory $countryFactory, + EavConfig $eavConfig ) { $this->directoryHelper = $directoryHelper; $this->countryFactory = $countryFactory; + $this->eavConfig = $eavConfig; + + if ($this->isTelephoneRequired()) { + $this->required['telephone'] = 'Phone Number'; + } } /** @@ -103,8 +114,11 @@ public function validateForCustomer(Address $address) if ($this->isEmpty($address->getCity())) { $errors[] = __('Please enter the city.'); } - if ($this->isEmpty($address->getTelephone())) { - $errors[] = __('Please enter the phone number.'); + + if ($this->isTelephoneRequired()) { + if ($this->isEmpty($address->getTelephone())) { + $errors[] = __('Please enter the phone number.'); + } } $countryId = $address->getCountryId(); @@ -155,4 +169,12 @@ protected function isStateRequired($countryId) $country = $this->countryFactory->create()->load($countryId); return $this->directoryHelper->isRegionRequired($countryId) && $country->getRegionCollection()->getSize(); } + + /** + * @return bool + */ + protected function isTelephoneRequired() + { + return ($this->eavConfig->getAttribute('customer_address', 'telephone')->getIsRequired()); + } } From 4c4990e11b214a66c8e020d30f0251404f220cf8 Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 15:15:41 +0100 Subject: [PATCH 09/15] Add server side validation for fax and company fields, depending on configuration --- .../Model/Address/AbstractAddress.php | 32 +++++++++++++++++ app/code/Magento/Customer/i18n/en_US.csv | 2 ++ .../Sales/Model/Order/Address/Validator.php | 36 +++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 207a6455655fa..475116fb94272 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -25,6 +25,8 @@ * @method int getCountryId() * @method string getCity() * @method string getTelephone() + * @method string getCompany() + * @method string getFax() * @method string getPostcode() * @method bool getShouldIgnoreValidation() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -586,6 +588,20 @@ public function validate() } } + if ($this->isFaxRequired()) { + if (!\Zend_Validate::is($this->getFax(), 'NotEmpty')) { + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'fax']); + + } + } + + if ($this->isCompanyRequired()) { + if (!\Zend_Validate::is($this->getCompany(), 'NotEmpty')) { + $errors[] = __('%fieldName is a required field.', ['fieldName' => 'company']); + + } + } + $_havingOptionalZip = $this->_directoryData->getCountriesWithOptionalZip(); if (!in_array( $this->getCountryId(), @@ -643,6 +659,14 @@ public function unsRegion() return $this->unsetData("region"); } + /** + * @return bool + */ + protected function isCompanyRequired() + { + return ($this->_eavConfig->getAttribute('customer_address', 'company')->getIsRequired()); + } + /** * @return bool */ @@ -650,4 +674,12 @@ protected function isTelephoneRequired() { return ($this->_eavConfig->getAttribute('customer_address', 'telephone')->getIsRequired()); } + + /** + * @return bool + */ + protected function isFaxRequired() + { + return ($this->_eavConfig->getAttribute('customer_address', 'fax')->getIsRequired()); + } } diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index 8847f6b604ec4..bff5c5520f630 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -192,6 +192,8 @@ Customers,Customers "Please enter the street.","Please enter the street." "Please enter the city.","Please enter the city." "Please enter the phone number.","Please enter the phone number." +"Please enter the fax number.","Please enter the fax number." +"Please enter the company.","Please enter the company." "Please enter the zip/postal code.","Please enter the zip/postal code." "Please enter the country.","Please enter the country." "Please enter the state/province.","Please enter the state/province." diff --git a/app/code/Magento/Sales/Model/Order/Address/Validator.php b/app/code/Magento/Sales/Model/Order/Address/Validator.php index 902e7482e3a77..b47085b059818 100644 --- a/app/code/Magento/Sales/Model/Order/Address/Validator.php +++ b/app/code/Magento/Sales/Model/Order/Address/Validator.php @@ -61,6 +61,14 @@ public function __construct( if ($this->isTelephoneRequired()) { $this->required['telephone'] = 'Phone Number'; } + + if ($this->isCompanyRequired()) { + $this->required['company'] = 'Company'; + } + + if ($this->isFaxRequired()) { + $this->required['fax'] = 'Fax'; + } } /** @@ -121,6 +129,18 @@ public function validateForCustomer(Address $address) } } + if ($this->isCompanyRequired()) { + if ($this->isEmpty($address->getCompany())) { + $errors[] = __('Please enter the company.'); + } + } + + if ($this->isFaxRequired()) { + if ($this->isEmpty($address->getFax())) { + $errors[] = __('Please enter the fax number.'); + } + } + $countryId = $address->getCountryId(); if ($this->isZipRequired($countryId) && $this->isEmpty($address->getPostcode())) { @@ -177,4 +197,20 @@ protected function isTelephoneRequired() { return ($this->eavConfig->getAttribute('customer_address', 'telephone')->getIsRequired()); } + + /** + * @return bool + */ + protected function isCompanyRequired() + { + return ($this->eavConfig->getAttribute('customer_address', 'company')->getIsRequired()); + } + + /** + * @return bool + */ + protected function isFaxRequired() + { + return ($this->eavConfig->getAttribute('customer_address', 'fax')->getIsRequired()); + } } From 92f8298c62010bb1327e6da47b5abe4ba4084e91 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sat, 11 Feb 2017 15:30:07 +0100 Subject: [PATCH 10/15] removed unused method --- app/code/Magento/Customer/Block/Widget/Telephone.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/code/Magento/Customer/Block/Widget/Telephone.php b/app/code/Magento/Customer/Block/Widget/Telephone.php index 49781f39d7c7b..40d2b5f920540 100644 --- a/app/code/Magento/Customer/Block/Widget/Telephone.php +++ b/app/code/Magento/Customer/Block/Widget/Telephone.php @@ -145,17 +145,6 @@ public function getAttributeValidationClass($attributeCode) return $this->_addressHelper->getAttributeValidationClass($attributeCode); } - /** - * @param string $attributeCode - * - * @return bool - */ - private function _isAttributeRequired($attributeCode) - { - $attributeMetadata = $this->_getAttribute($attributeCode); - return $attributeMetadata ? (bool)$attributeMetadata->isRequired() : false; - } - /** * @param string $attributeCode * From 7b1df3646cd1cf6bd06a1834fc09c7cb92f83f99 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sat, 11 Feb 2017 15:33:09 +0100 Subject: [PATCH 11/15] Enabled toggling of frontend fields for company and fax - added supporting blocks --- .../Magento/Customer/Block/Widget/Company.php | 180 ++++++++++++++++++ .../Magento/Customer/Block/Widget/Fax.php | 180 ++++++++++++++++++ .../frontend/templates/address/edit.phtml | 32 +--- .../frontend/templates/form/register.phtml | 16 +- .../frontend/templates/widget/company.phtml | 17 ++ .../view/frontend/templates/widget/fax.phtml | 17 ++ 6 files changed, 414 insertions(+), 28 deletions(-) create mode 100644 app/code/Magento/Customer/Block/Widget/Company.php create mode 100644 app/code/Magento/Customer/Block/Widget/Fax.php create mode 100644 app/code/Magento/Customer/view/frontend/templates/widget/company.phtml create mode 100644 app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml diff --git a/app/code/Magento/Customer/Block/Widget/Company.php b/app/code/Magento/Customer/Block/Widget/Company.php new file mode 100644 index 0000000000000..c6192ce5912cc --- /dev/null +++ b/app/code/Magento/Customer/Block/Widget/Company.php @@ -0,0 +1,180 @@ +options = $options; + parent::__construct($context, $addressHelper, $customerMetadata, $data); + $this->addressMetadata = $addressMetadata; + $this->_isScopePrivate = true; + } + + /** + * @return void + */ + public function _construct() + { + parent::_construct(); + + // default template location + $this->setTemplate('widget/company.phtml'); + } + + /** + * Can show config value + * + * @param string $key + * + * @return bool + */ + protected function _showConfig($key) + { + return (bool)$this->getConfig($key); + } + + /** + * Can show prefix + * + * @return bool + */ + public function showCompany() + { + return $this->_isAttributeVisible(self::ATTRIBUTE_CODE); + } + + /** + * {@inheritdoc} + */ + protected function _getAttribute($attributeCode) + { + if ($this->getForceUseCustomerAttributes() || $this->getObject() instanceof CustomerInterface) { + return parent::_getAttribute($attributeCode); + } + + try { + $attribute = $this->addressMetadata->getAttributeMetadata($attributeCode); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + return null; + } + + if ($this->getForceUseCustomerRequiredAttributes() && $attribute && !$attribute->isRequired()) { + $customerAttribute = parent::_getAttribute($attributeCode); + if ($customerAttribute && $customerAttribute->isRequired()) { + $attribute = $customerAttribute; + } + } + + return $attribute; + } + + /** + * Retrieve store attribute label + * + * @param string $attributeCode + * + * @return string + */ + public function getStoreLabel($attributeCode) + { + $attribute = $this->_getAttribute($attributeCode); + return $attribute ? __($attribute->getStoreLabel()) : ''; + } + + /** + * Get string with frontend validation classes for attribute + * + * @param string $attributeCode + * + * @return string + */ + public function getAttributeValidationClass($attributeCode) + { + return $this->_addressHelper->getAttributeValidationClass($attributeCode); + } + + /** + * @param string $attributeCode + * + * @return bool + */ + private function _isAttributeVisible($attributeCode) + { + $attributeMetadata = $this->_getAttribute($attributeCode); + return $attributeMetadata ? (bool)$attributeMetadata->isVisible() : false; + } + + /** + * Check if company attribute enabled in system + * + * @return bool + */ + public function isEnabled() + { + return $this->_getAttribute(self::ATTRIBUTE_CODE) ? (bool)$this->_getAttribute(self::ATTRIBUTE_CODE)->isVisible( + ) : false; + } + + /** + * Check if company attribute marked as required + * + * @return bool + */ + public function isRequired() + { + return $this->_getAttribute(self::ATTRIBUTE_CODE) ? (bool)$this->_getAttribute(self::ATTRIBUTE_CODE) + ->isRequired() : false; + } +} diff --git a/app/code/Magento/Customer/Block/Widget/Fax.php b/app/code/Magento/Customer/Block/Widget/Fax.php new file mode 100644 index 0000000000000..5f4e51724d14c --- /dev/null +++ b/app/code/Magento/Customer/Block/Widget/Fax.php @@ -0,0 +1,180 @@ +options = $options; + parent::__construct($context, $addressHelper, $customerMetadata, $data); + $this->addressMetadata = $addressMetadata; + $this->_isScopePrivate = true; + } + + /** + * @return void + */ + public function _construct() + { + parent::_construct(); + + // default template location + $this->setTemplate('widget/fax.phtml'); + } + + /** + * Can show config value + * + * @param string $key + * + * @return bool + */ + protected function _showConfig($key) + { + return (bool)$this->getConfig($key); + } + + /** + * Can show prefix + * + * @return bool + */ + public function showFax() + { + return $this->_isAttributeVisible(self::ATTRIBUTE_CODE); + } + + /** + * {@inheritdoc} + */ + protected function _getAttribute($attributeCode) + { + if ($this->getForceUseCustomerAttributes() || $this->getObject() instanceof CustomerInterface) { + return parent::_getAttribute($attributeCode); + } + + try { + $attribute = $this->addressMetadata->getAttributeMetadata($attributeCode); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + return null; + } + + if ($this->getForceUseCustomerRequiredAttributes() && $attribute && !$attribute->isRequired()) { + $customerAttribute = parent::_getAttribute($attributeCode); + if ($customerAttribute && $customerAttribute->isRequired()) { + $attribute = $customerAttribute; + } + } + + return $attribute; + } + + /** + * Retrieve store attribute label + * + * @param string $attributeCode + * + * @return string + */ + public function getStoreLabel($attributeCode) + { + $attribute = $this->_getAttribute($attributeCode); + return $attribute ? __($attribute->getStoreLabel()) : ''; + } + + /** + * Get string with frontend validation classes for attribute + * + * @param string $attributeCode + * + * @return string + */ + public function getAttributeValidationClass($attributeCode) + { + return $this->_addressHelper->getAttributeValidationClass($attributeCode); + } + + /** + * @param string $attributeCode + * + * @return bool + */ + private function _isAttributeVisible($attributeCode) + { + $attributeMetadata = $this->_getAttribute($attributeCode); + return $attributeMetadata ? (bool)$attributeMetadata->isVisible() : false; + } + + /** + * Check if company attribute enabled in system + * + * @return bool + */ + public function isEnabled() + { + return $this->_getAttribute(self::ATTRIBUTE_CODE) ? (bool)$this->_getAttribute(self::ATTRIBUTE_CODE)->isVisible( + ) : false; + } + + /** + * Check if company attribute marked as required + * + * @return bool + */ + public function isRequired() + { + return $this->_getAttribute(self::ATTRIBUTE_CODE) ? (bool)$this->_getAttribute(self::ATTRIBUTE_CODE) + ->isRequired() : false; + } +} diff --git a/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml b/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml index ab8ea6fd43533..b2a8ac8518a34 100644 --- a/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml @@ -8,7 +8,9 @@ /** @var \Magento\Customer\Block\Address\Edit $block */ ?> +getLayout()->createBlock('Magento\Customer\Block\Widget\Company') ?> getLayout()->createBlock('Magento\Customer\Block\Widget\Telephone') ?> +getLayout()->createBlock('Magento\Customer\Block\Widget\Fax') ?> getNameBlockHtml() ?> -
- -
- -
-
+ + isEnabled()): ?> + setCompany($block->getAddress()->getCompany())->toHtml() ?> + isEnabled()): ?> setTelephone($block->getAddress()->getTelephone())->toHtml() ?> -
- -
- -
-
+ isEnabled()): ?> + setFax($block->getAddress()->getFax())->toHtml() ?> + +
escapeHtml(__('Address')) ?>
diff --git a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml index 6f08bf4a16d8c..8e7cbef93fcbd 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml @@ -45,18 +45,22 @@
escapeHtml(__('Address Information')) ?>
-
- -
- -
-
+ + getLayout()->createBlock('Magento\Customer\Block\Widget\Company') ?> + isEnabled()): ?> + setCompany($block->getFormData()->getCompany())->toHtml() ?> + getLayout()->createBlock('Magento\Customer\Block\Widget\Telephone') ?> isEnabled()): ?> setTelephone($block->getFormData()->getTelephone())->toHtml() ?> + getLayout()->createBlock('Magento\Customer\Block\Widget\Fax') ?> + isEnabled()): ?> + setFax($block->getFormData()->getFax())->toHtml() ?> + + helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?>
diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml new file mode 100644 index 0000000000000..7d235d8dcd747 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml @@ -0,0 +1,17 @@ + + +
+ +
+ +
+
\ No newline at end of file diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml new file mode 100644 index 0000000000000..3dece4b2704a0 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml @@ -0,0 +1,17 @@ + + +
+ +
+ +
+
\ No newline at end of file From 724a552b5827be32304bb161a959ab99f6ca1e42 Mon Sep 17 00:00:00 2001 From: Andreas von Studnitz Date: Sat, 11 Feb 2017 16:50:32 +0100 Subject: [PATCH 12/15] Add Integration Tests about register form and widgets --- .../Customer/Block/Form/RegisterTest.php | 134 ++++++++++++++++++ .../Customer/Block/Widget/CompanyTest.php | 57 ++++++++ .../Magento/Customer/Block/Widget/FaxTest.php | 57 ++++++++ .../Customer/Block/Widget/TelephoneTest.php | 57 ++++++++ 4 files changed, 305 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Form/RegisterTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Widget/CompanyTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Widget/FaxTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TelephoneTest.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Form/RegisterTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Form/RegisterTest.php new file mode 100644 index 0000000000000..4fbad9d01fd73 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Form/RegisterTest.php @@ -0,0 +1,134 @@ +create( + \Magento\Customer\Block\Form\Register::class + )->setTemplate('Magento_Customer::form/register.phtml') + ->setShowAddressFields(true); + + $this->assertContains('title="Company"', $block->toHtml()); + } + + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testTelephoneDefault() + { + /** @var \Magento\Customer\Block\Widget\Company $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Form\Register::class + )->setTemplate('Magento_Customer::form/register.phtml') + ->setShowAddressFields(true); + + $this->assertContains('title="Phone Number"', $block->toHtml()); + } + + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testFaxDefault() + { + /** @var \Magento\Customer\Block\Widget\Company $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Form\Register::class + )->setTemplate('Magento_Customer::form/register.phtml') + ->setShowAddressFields(true); + + $this->assertNotContains('title="Fax"', $block->toHtml()); + } + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testCompanyDisabled() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class + ); + $model->loadByCode('customer_address', 'company')->setIsVisible('0'); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Company $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Form\Register::class + )->setTemplate('Magento_Customer::form/register.phtml') + ->setShowAddressFields(true); + + $this->assertNotContains('title="Company"', $block->toHtml()); + } + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testTelephoneDisabled() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class + ); + $model->loadByCode('customer_address', 'telephone')->setIsVisible('0'); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Company $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Form\Register::class + )->setTemplate('Magento_Customer::form/register.phtml') + ->setShowAddressFields(true); + + $this->assertNotContains('title="Phone Number"', $block->toHtml()); + } + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testFaxEnabled() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class + ); + $model->loadByCode('customer_address', 'fax')->setIsVisible('1'); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Company $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Form\Register::class + )->setTemplate('Magento_Customer::form/register.phtml') + ->setShowAddressFields(true); + + $this->assertContains('title="Fax"', $block->toHtml()); + } + + protected function tearDown() + { + /** @var \Magento\Eav\Model\Config $eavConfig */ + $eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class); + $eavConfig->clear(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/CompanyTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/CompanyTest.php new file mode 100644 index 0000000000000..e026e930523fd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/CompanyTest.php @@ -0,0 +1,57 @@ +create( + \Magento\Customer\Block\Widget\Company::class + ); + + $this->assertContains('title="Company"', $block->toHtml()); + $this->assertNotContains('required', $block->toHtml()); + } + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testToHtmlRequired() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class + ); + $model->loadByCode('customer_address', 'company')->setIsRequired(true); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Company $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Widget\Company::class + ); + + $this->assertContains('title="Company"', $block->toHtml()); + $this->assertContains('required', $block->toHtml()); + } + + protected function tearDown() + { + /** @var \Magento\Eav\Model\Config $eavConfig */ + $eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class); + $eavConfig->clear(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/FaxTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/FaxTest.php new file mode 100644 index 0000000000000..73a69d2fa104e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/FaxTest.php @@ -0,0 +1,57 @@ +create( + \Magento\Customer\Block\Widget\Fax::class + ); + + $this->assertContains('title="Fax"', $block->toHtml()); + $this->assertNotContains('required', $block->toHtml()); + } + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testToHtmlRequired() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class + ); + $model->loadByCode('customer_address', 'fax')->setIsRequired(true); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Fax $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Widget\Fax::class + ); + + $this->assertContains('title="Fax"', $block->toHtml()); + $this->assertContains('required', $block->toHtml()); + } + + protected function tearDown() + { + /** @var \Magento\Eav\Model\Config $eavConfig */ + $eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class); + $eavConfig->clear(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TelephoneTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TelephoneTest.php new file mode 100644 index 0000000000000..f3a605afe3763 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Widget/TelephoneTest.php @@ -0,0 +1,57 @@ +create( + \Magento\Customer\Block\Widget\Telephone::class + ); + + $this->assertContains('title="Phone Number"', $block->toHtml()); + $this->assertContains('required', $block->toHtml()); + } + + /** + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ + public function testToHtmlRequired() + { + /** @var \Magento\Customer\Model\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class + ); + $model->loadByCode('customer_address', 'telephone')->setIsRequired(false); + $model->save(); + + /** @var \Magento\Customer\Block\Widget\Telephone $block */ + $block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Block\Widget\Telephone::class + ); + + $this->assertContains('title="Phone Number"', $block->toHtml()); + $this->assertNotContains('required', $block->toHtml()); + } + + protected function tearDown() + { + /** @var \Magento\Eav\Model\Config $eavConfig */ + $eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class); + $eavConfig->clear(); + } +} From 5814ef47fdd7b046598d4dc565aae6acb50c6e5e Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sun, 12 Feb 2017 08:41:07 +0100 Subject: [PATCH 13/15] updated formatting of templates --- .../frontend/templates/widget/company.phtml | 25 +++++++++++++++---- .../view/frontend/templates/widget/fax.phtml | 24 +++++++++++++++--- .../frontend/templates/widget/telephone.phtml | 22 +++++++++++++--- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml index 7d235d8dcd747..007a9f03eb6b7 100644 --- a/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/widget/company.phtml @@ -8,10 +8,25 @@ /** @var \Magento\Customer\Block\Widget\Company $block */ ?> - -
- +
+
- + escapeHtmlAttr( + $this->helper('Magento\Customer\Helper\Address') + ->getAttributeValidationClass('company') + ); + ?> +
-
\ No newline at end of file +
diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml index 3dece4b2704a0..b552f056e40d4 100644 --- a/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/widget/fax.phtml @@ -9,9 +9,25 @@ /** @var \Magento\Customer\Block\Widget\Fax $block */ ?> -
- +
+
- + escapeHtmlAttr( + $this->helper('Magento\Customer\Helper\Address') + ->getAttributeValidationClass('fax') + ); + ?> +
-
\ No newline at end of file +
diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml index 5b995e6f647ee..e36568c5e7268 100644 --- a/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/widget/telephone.phtml @@ -9,9 +9,25 @@ /** @var \Magento\Customer\Block\Widget\Telephone $block */ ?> -
- +
+
- + escapeHtmlAttr( + $this->helper('Magento\Customer\Helper\Address') + ->getAttributeValidationClass('fax') + ); + ?> +
From 665867cc3194c0c5a9ddb9132ed8998bd200ca36 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sun, 12 Feb 2017 08:45:22 +0100 Subject: [PATCH 14/15] added missing EavConfig docblock param --- app/code/Magento/Sales/Model/Order/Address/Validator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/Order/Address/Validator.php b/app/code/Magento/Sales/Model/Order/Address/Validator.php index b47085b059818..c0deb7e9c7454 100644 --- a/app/code/Magento/Sales/Model/Order/Address/Validator.php +++ b/app/code/Magento/Sales/Model/Order/Address/Validator.php @@ -47,7 +47,8 @@ class Validator /** * @param DirectoryHelper $directoryHelper - * @param CountryFactory $countryFactory + * @param CountryFactory $countryFactory + * @param EavConfig $eavConfig */ public function __construct( DirectoryHelper $directoryHelper, From e68f72c17dd156d04795fb923b42250b324fa363 Mon Sep 17 00:00:00 2001 From: Andre Flitsch Date: Sun, 12 Feb 2017 09:04:26 +0100 Subject: [PATCH 15/15] made EavConfig an optional param --- app/code/Magento/Sales/Model/Order/Address/Validator.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Address/Validator.php b/app/code/Magento/Sales/Model/Order/Address/Validator.php index c0deb7e9c7454..20f51eb6c608b 100644 --- a/app/code/Magento/Sales/Model/Order/Address/Validator.php +++ b/app/code/Magento/Sales/Model/Order/Address/Validator.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Model\Order\Address; use Magento\Eav\Model\Config as EavConfig; +use Magento\Framework\App\ObjectManager; use Magento\Sales\Model\Order\Address; use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Directory\Model\CountryFactory; @@ -53,11 +54,12 @@ class Validator public function __construct( DirectoryHelper $directoryHelper, CountryFactory $countryFactory, - EavConfig $eavConfig + EavConfig $eavConfig = null ) { $this->directoryHelper = $directoryHelper; $this->countryFactory = $countryFactory; - $this->eavConfig = $eavConfig; + $this->eavConfig = $eavConfig ?: ObjectManager::getInstance() + ->get(EavConfig::class); if ($this->isTelephoneRequired()) { $this->required['telephone'] = 'Phone Number';