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

FEATURE: Add autocomplete attribute to form fields #620

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
46 changes: 46 additions & 0 deletions Classes/Domain/Model/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use In2code\Powermail\Domain\Repository\FieldRepository;
use In2code\Powermail\Exception\DeprecatedException;
use In2code\Powermail\Enumeration\AutocompleteType;
use In2code\Powermail\Utility\BackendUtility;
use In2code\Powermail\Utility\FrontendUtility;
use In2code\Powermail\Utility\ObjectUtility;
Expand Down Expand Up @@ -145,6 +146,24 @@ class Field extends AbstractEntity
*/
protected $page = null;

/**
* autocomplete
* Powermail field autocomplete types are:
* "on", "off", "name", "honorific-prefix", "given-name", "additional-name", "family-name",
* "honorific-suffix", "nickname", "username", "new-password", "current-password",
* "organization-title", "organization", "street-address", "address-line1", "address-line2",
* "address-line3", "address-level4", "address-level3", "address-level2",
* "address-level1", "country", "country-name", "postal-code", "cc-name",
* "cc-given-name", "cc-additional-name", "cc-family-name", "cc-number", "cc-exp",
* "cc-exp-month", "cc-exp-year", "cc-csc", "cc-type", "transaction-currency",
* "transaction-amount", "language", "bday", "bday-day", "bday-month", "bday-year",
* "sex", "url", "photo", "tel", "tel-country-code", "tel-national", "tel-area-code",
* "tel-local", "tel-local-prefix", "tel-local-suffix", "tel-extension", "email", "impp"
*
* @var string
*/
protected $autocomplete = '';

/**
* @return string
* @throws Exception
Expand Down Expand Up @@ -823,4 +842,31 @@ protected function getExportableTypesFromTypoScript(): array
}
return $types;
}

/**
* Returns the autocomplete. If the autocomplete value is invalid we return off state.
*
* @return string $autocomplete
*/
public function getAutocomplete()
{
try {
$autocomplete = AutocompleteType::cast($this->autocomplete);
} catch (\TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException $exception) {
$autocomplete = AutocompleteType::cast(AutocompleteType::OFF);
}

return $autocomplete;
}

/**
* Sets the autocomplete type
*
* @param string $autocomplete
* @return void
*/
public function setAutocomplete($autocomplete)
{
$this->autocomplete = $autocomplete;
}
}
79 changes: 79 additions & 0 deletions Classes/Enumeration/AutocompleteType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace In2code\Powermail\Enumeration;

/**
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Type\Enumeration;

class AutocompleteType extends Enumeration
{

const ON = 'on';
const OFF = 'off';
const NAME = 'name';
const HONORIFIC_PREFIX = 'honorific-prefix';
const GIVEN_NAME = 'given-name';
const ADDITIONAL_NAME = 'additional-name';
const FAMILY_NAME = 'family-name';
const HONORIFIC_SUFFIX = 'honorific-suffix';
const NICKNAME = 'nickname';
const USERNAME = 'username';
const NEW_PASSWORD = 'new-password';
const CURRENT_PASSWORD = 'current-password';
const ORGANIZATION_TITLE = 'organization-title';
const ORGANIZATION = 'organization';
const STREET_ADDRESS = 'street-address';
const ADDRESS_LINE1 = 'address-line1';
const ADDRESS_LINE2 = 'address-line2';
const ADDRESS_LINE3 = 'address-line3';
const ADDRESS_LEVEL4 = 'address-level4';
const ADDRESS_LEVEL3 = 'address-level3';
const ADDRESS_LEVEL2 = 'address-level2';
const ADDRESS_LEVEL1 = 'address-level1';
const COUNTRY = 'country';
const COUNTRY_NAME = 'country-name';
const POSTAL_CODE = 'postal-code';
const CC_NAME = 'cc-name';
const CC_GIVEN_NAME = 'cc-given-name';
const CC_ADDITIONAL_NAME = 'cc-additional-name';
const CC_FAMILY_NAME = 'cc-family-name';
const CC_NUMBER = 'cc-number';
const CC_EXP = 'cc-exp';
const CC_EXP_MONTH = 'cc-exp-month';
const CC_EXP_YEAR = 'cc-exp-year';
const CC_CSC = 'cc-csc';
const CC_TYPE = 'cc-type';
const TRANSACTION_CURRENCY = 'transaction-currency';
const TRANSACTION_AMOUNT = 'transaction-amount';
const LANGUAGE = 'language';
const BDAY = 'bday';
const BDAY_DAY = 'bday-day';
const BDAY_MONTH = 'bday-month';
const BDAY_YEAR = 'bday-year';
const SEX = 'sex';
const URL = 'url';
const PHOTO = 'photo';
const TEL = 'tel';
const TEL_COUNTRY_CODE = 'tel-country-code';
const TEL_NATIONAL = 'tel-national';
const TEL_AREA_CODE = 'tel-area-code';
const TEL_LOCAL = 'tel-local';
const TEL_LOCAL_PREFIX = 'tel-local-prefix';
const TEL_LOCAL_SUFFIX = 'tel-local-suffix';
const TEL_EXTENSION = 'tel-extension';
const EMAIL = 'email';
const IMPP = 'impp';

}
Loading