Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Add all form fields to validation setup #446

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,39 @@ plugin.tx_cart {
billingAddress {
fields {
salutation.validator = NotEmpty
title.validator = Empty
firstName.validator = NotEmpty
lastName.validator = NotEmpty
email.validator = NotEmpty
phone.validator = Empty
fax.validator = Empty
company.validator = Empty
taxIdentificationNumber.validator = Empty
street.validator = NotEmpty
streetNumber.validator = Empty
addition.validator = Empty
zip.validator = NotEmpty
city.validator = NotEmpty
country.validator = NotEmpty
}
}
shippingAddress {
fields {
salutation.validator = NotEmpty
title.validator = Empty
firstName.validator = NotEmpty
lastName.validator = NotEmpty
email.validator = NotEmpty
phone.validator = Empty
fax.validator = Empty
company.validator = Empty
taxIdentificationNumber.validator = Empty
street.validator = NotEmpty
streetNumber.validator = Empty
addition.validator = Empty
zip.validator = NotEmpty
city.validator = NotEmpty
country.validator = NotEmpty
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ plugin.tx_cart {
salutation {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.salutation.validator}
}
title {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.title.validator}
}
firstName {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.firstName.validator}
}
Expand All @@ -180,6 +183,12 @@ plugin.tx_cart {
fax {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.fax.validator}
}
company {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.company.validator}
}
taxIdentificationNumber {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.taxIdentificationNumber.validator}
}
street {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.street.validator}
}
Expand All @@ -195,13 +204,19 @@ plugin.tx_cart {
city {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.city.validator}
}
country {
validator = {$plugin.tx_cart.settings.validation.billingAddress.fields.country.validator}
}
}
}
shippingAddress {
fields {
salutation {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.salutation.validator}
}
title {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.title.validator}
}
firstName {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.firstName.validator}
}
Expand All @@ -217,6 +232,12 @@ plugin.tx_cart {
fax {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.fax.validator}
}
company {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.company.validator}
}
taxIdentificationNumber {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.taxIdentificationNumber.validator}
}
street {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.street.validator}
}
Expand All @@ -232,6 +253,9 @@ plugin.tx_cart {
city {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.city.validator}
}
country {
validator = {$plugin.tx_cart.settings.validation.shippingAddress.fields.country.validator}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
Validating and hiding fields
============================

Using this TypoScript configuration it is possible to change the validation and
rendering of fields of the billing and shipping address.

Using the below shown TypoScript configuration allows to change the validation
and rendering of fields of the billing and shipping address.
The partials for the display of the addresses evaluates this configuration.
It controls whether the fields are mandatory, optional or not rendered att all.
It controls whether the fields are mandatory, optional or not rendered at all.

.. TIP::
This way it is easily possible to unhide e.g the fields `streetNumber` or
`addition` (which is a field for additional address information) which are
already defined but hidden by default.

Have a look at all fields with the value `Empty` to see all available
fields.


.. code-block:: typoscript
:caption: EXT:cart/Configuration/TypoScript/setup.typoscript
Expand All @@ -21,31 +29,39 @@ It controls whether the fields are mandatory, optional or not rendered att all.
billingAddress {
fields {
salutation.validator = NotEmpty
title.validator = Empty
firstName.validator = NotEmpty
lastName.validator = NotEmpty
email.validator = NotEmpty
phone.validator = Empty
fax.validator = Empty
company.validator = Empty
taxIdentificationNumber.validator = Empty
street.validator = NotEmpty
streetNumber.validator = Empty
addition.validator = Empty
zip.validator = NotEmpty
city.validator = NotEmpty
country.validator = NotEmpty
}
}
shippingAddress {
fields {
salutation.validator = NotEmpty
title.validator = Empty
firstName.validator = NotEmpty
lastName.validator = NotEmpty
email.validator = NotEmpty
phone.validator = Empty
fax.validator = Empty
company.validator = Empty
taxIdentificationNumber.validator = Empty
street.validator = NotEmpty
streetNumber.validator = Empty
addition.validator = Empty
zip.validator = NotEmpty
city.validator = NotEmpty
country.validator = NotEmpty
}
}
}
Expand All @@ -68,6 +84,7 @@ Option `Not Empty`
* The input field is rendered with the attribute `required` set to `true`.

.. code-block:: typoscript
:caption: EXT:sitepackage/Configuration/TypoScript/constants.typoscript

plugin.tx_cart.settings.validation.billingAddress.fields {
salutation.validator = NotEmpty
Expand All @@ -82,6 +99,7 @@ Option `Empty`
* The server checks whether the field is empty.

.. code-block:: typoscript
:caption: EXT:sitepackage/Configuration/TypoScript/constants.typoscript

plugin.tx_cart.settings.validation.billingAddress.fields {
salutation.validator = Empty
Expand All @@ -96,7 +114,12 @@ This has the following consequences:
* The label of the field is rendered without a trailing "*".
* The input field is rendered without the attribute `required`.

.. IMPORTANT::
While the two configuration above can be made within the
`constants.typoscript` is this configuration done in `setup.typoscript`.

.. code-block:: typoscript
:caption: EXT:sitepackage/Configuration/TypoScript/setup.typoscript

plugin.tx_cart.settings.validation.billingAddress.fields {
# !!! It is necessary to remove the whole address field,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. include:: ../../Includes.txt

=========================================================
Breaking: #445 - Include all address fields in validation
=========================================================

See :issue:`445`

Description
===========

All fields which exists for the billing address and for the shipping address
are now included within the validation array in TypoScript. The fields
`title`, `company`, `taxIdentificationNumber` and `country` were not included.
Including those fields makes it easier and especially more logic to manage
the validation and visibility of those fields.

Affected Installations
======================

By default the fields `title`, `company` and `taxIdentificationNumber` will
not be rendered, the field country will be rendered and required.

Migration
=========

See :ref:`validating-and-hiding-fields` how to manage the visibility and
validation of address fields.

.. index:: Template, Frontend, TypoScript
Loading