Skip to content

Commit a59dea0

Browse files
FEATURE: Add autocomplete attribute to form fields
For accessibility reasons form elements should have autocomplete fields. To have just autocomplete with value on or off does not bring much value for the user. So form editors should be able to define the field content type so that the auto complete knows which data could be used.
1 parent 53cac87 commit a59dea0

File tree

14 files changed

+843
-7
lines changed

14 files changed

+843
-7
lines changed

Classes/Domain/Model/Field.php

+46
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use In2code\Powermail\Domain\Repository\FieldRepository;
66
use In2code\Powermail\Exception\DeprecatedException;
7+
use In2code\Powermail\Enumeration\AutocompleteType;
78
use In2code\Powermail\Utility\BackendUtility;
89
use In2code\Powermail\Utility\FrontendUtility;
910
use In2code\Powermail\Utility\ObjectUtility;
@@ -145,6 +146,24 @@ class Field extends AbstractEntity
145146
*/
146147
protected $page = null;
147148

149+
/**
150+
* autocomplete
151+
* Powermail field autocomplete types are:
152+
* "on", "off", "name", "honorific-prefix", "given-name", "additional-name", "family-name",
153+
* "honorific-suffix", "nickname", "username", "new-password", "current-password",
154+
* "organization-title", "organization", "street-address", "address-line1", "address-line2",
155+
* "address-line3", "address-level4", "address-level3", "address-level2",
156+
* "address-level1", "country", "country-name", "postal-code", "cc-name",
157+
* "cc-given-name", "cc-additional-name", "cc-family-name", "cc-number", "cc-exp",
158+
* "cc-exp-month", "cc-exp-year", "cc-csc", "cc-type", "transaction-currency",
159+
* "transaction-amount", "language", "bday", "bday-day", "bday-month", "bday-year",
160+
* "sex", "url", "photo", "tel", "tel-country-code", "tel-national", "tel-area-code",
161+
* "tel-local", "tel-local-prefix", "tel-local-suffix", "tel-extension", "email", "impp"
162+
*
163+
* @var string
164+
*/
165+
protected $autocomplete = '';
166+
148167
/**
149168
* @return string
150169
* @throws Exception
@@ -823,4 +842,31 @@ protected function getExportableTypesFromTypoScript(): array
823842
}
824843
return $types;
825844
}
845+
846+
/**
847+
* Returns the autocomplete. If the autocomplete value is invalid we return off state.
848+
*
849+
* @return string $autocomplete
850+
*/
851+
public function getAutocomplete()
852+
{
853+
try {
854+
$autocomplete = AutocompleteType::cast($this->autocomplete);
855+
} catch (\TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException $exception) {
856+
$autocomplete = AutocompleteType::cast(AutocompleteType::OFF);
857+
}
858+
859+
return $autocomplete;
860+
}
861+
862+
/**
863+
* Sets the autocomplete type
864+
*
865+
* @param string $autocomplete
866+
* @return void
867+
*/
868+
public function setAutocomplete($autocomplete)
869+
{
870+
$this->autocomplete = $autocomplete;
871+
}
826872
}
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
declare(strict_types=1);
3+
namespace In2code\Powermail\Enumeration;
4+
5+
/**
6+
* This file is part of the TYPO3 CMS project.
7+
*
8+
* It is free software; you can redistribute it and/or modify it under
9+
* the terms of the GNU General Public License, either version 2
10+
* of the License, or any later version.
11+
*
12+
* For the full copyright and license information, please read the
13+
* LICENSE.txt file that was distributed with this source code.
14+
*
15+
* The TYPO3 project - inspiring people to share!
16+
*/
17+
18+
use TYPO3\CMS\Core\Type\Enumeration;
19+
20+
class AutocompleteType extends Enumeration
21+
{
22+
23+
const ON = 'on';
24+
const OFF = 'off';
25+
const NAME = 'name';
26+
const HONORIFIC_PREFIX = 'honorific-prefix';
27+
const GIVEN_NAME = 'given-name';
28+
const ADDITIONAL_NAME = 'additional-name';
29+
const FAMILY_NAME = 'family-name';
30+
const HONORIFIC_SUFFIX = 'honorific-suffix';
31+
const NICKNAME = 'nickname';
32+
const USERNAME = 'username';
33+
const NEW_PASSWORD = 'new-password';
34+
const CURRENT_PASSWORD = 'current-password';
35+
const ORGANIZATION_TITLE = 'organization-title';
36+
const ORGANIZATION = 'organization';
37+
const STREET_ADDRESS = 'street-address';
38+
const ADDRESS_LINE1 = 'address-line1';
39+
const ADDRESS_LINE2 = 'address-line2';
40+
const ADDRESS_LINE3 = 'address-line3';
41+
const ADDRESS_LEVEL4 = 'address-level4';
42+
const ADDRESS_LEVEL3 = 'address-level3';
43+
const ADDRESS_LEVEL2 = 'address-level2';
44+
const ADDRESS_LEVEL1 = 'address-level1';
45+
const COUNTRY = 'country';
46+
const COUNTRY_NAME = 'country-name';
47+
const POSTAL_CODE = 'postal-code';
48+
const CC_NAME = 'cc-name';
49+
const CC_GIVEN_NAME = 'cc-given-name';
50+
const CC_ADDITIONAL_NAME = 'cc-additional-name';
51+
const CC_FAMILY_NAME = 'cc-family-name';
52+
const CC_NUMBER = 'cc-number';
53+
const CC_EXP = 'cc-exp';
54+
const CC_EXP_MONTH = 'cc-exp-month';
55+
const CC_EXP_YEAR = 'cc-exp-year';
56+
const CC_CSC = 'cc-csc';
57+
const CC_TYPE = 'cc-type';
58+
const TRANSACTION_CURRENCY = 'transaction-currency';
59+
const TRANSACTION_AMOUNT = 'transaction-amount';
60+
const LANGUAGE = 'language';
61+
const BDAY = 'bday';
62+
const BDAY_DAY = 'bday-day';
63+
const BDAY_MONTH = 'bday-month';
64+
const BDAY_YEAR = 'bday-year';
65+
const SEX = 'sex';
66+
const URL = 'url';
67+
const PHOTO = 'photo';
68+
const TEL = 'tel';
69+
const TEL_COUNTRY_CODE = 'tel-country-code';
70+
const TEL_NATIONAL = 'tel-national';
71+
const TEL_AREA_CODE = 'tel-area-code';
72+
const TEL_LOCAL = 'tel-local';
73+
const TEL_LOCAL_PREFIX = 'tel-local-prefix';
74+
const TEL_LOCAL_SUFFIX = 'tel-local-suffix';
75+
const TEL_EXTENSION = 'tel-extension';
76+
const EMAIL = 'email';
77+
const IMPP = 'impp';
78+
79+
}

0 commit comments

Comments
 (0)