2017 © Pedro Peláez
 

typo3-cms-extension form-element-linked-checkbox

image

tritum/form-element-linked-checkbox

  • Thursday, June 7, 2018
  • by tritum
  • Repository
  • 1 Watchers
  • 5 Stars
  • 341 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

TYPO3 extension Total downloads Stability CGL TYPO3 versions Latest version, (*1)

Custom form element "Linked checkbox"

This TYPO3 extension adds a custom form element "Linked checkbox" to the TYPO3 form framework. The user is able to define the link target and the link text., (*2)

Known incompatibilities

This extension is not fully compatible with EXT:form-mailtext. Both extensions override the same Fluid templates. Create a copy within your site package, adapt the template accordingly and configure TYPO3 properly to use this template., (*3)

Installation and configuration

Preferred Installation

  1. Require the extension via composer.
  2. Add the static TypoScript configuration to your TypoScript template.

Customization

The extension overrides templates for the following views: * email to receiver, plain text * email to receiver, HTML * email to sender, plain text * email to sender, HTML * summary page, (*4)

This is necessary to render links correctly. By default, the core templates of the form framework escape any HTML in both email and plain text mails. Thus, your users would receive mails with broken links., (*5)

If you also override those templates, please adopt your files accordingly., (*6)

Usage

Open the TYPO3 form editor and create a new form/open an existing one. Add a new element to your form. The modal will list the new custom form element "Linked checkbox". Provide a label for the checkbox including the link text. Select a page you want to link to., (*7)

The default label consists of the label itself, followed by a link to the specified page with the given link text., (*8)

Example:, (*9)

  • Label: I accept the
  • Link text: terms and conditions.
  • Output: I accept the <a href="/terms" target="_blank">terms and conditions.</a>

If want to use the link inside your label, define the link position in the label with a character substitution. We highly recommend this way., (*10)

Example:, (*11)

  • Label: I have read the %s and accept them.
  • Link text: terms and conditions
  • Output: I have read the <a href="/terms" target="_blank">terms and conditions</a> and accept them.

You can also use more than one link in the checkbox label. For this, just use the field additionalLinks and provide a combination of Page UID and link text., (*12)

Example:, (*13)

  • Label: I have read the %s and %s and accept them.
  • Link text: terms and conditions
  • Additional links:
    • privacy policy
  • Output: I have read the <a href="/terms" target="_blank">terms and conditions</a> and <a href="/privacy-policy" target="_blank">privacy policy</a> and accept them.

You can provide additional link configuration which will be used when generating the link within the label. Note that this can only be defined in the appropriate .form.yaml file but not in the form editor and applies to all generated links., (*14)

type: LinkedCheckbox
identifier: consent
label: 'I accept the %s and %s.'
properties:
  pageUid: '67'
  linkText: 'terms and conditions'
  additionalLinks:
    83: 'privacy policy'

renderingOptions:
  linkConfiguration:
    # Additional typolink configuration can be inserted here, e.g.:
    no_cache: 1

For a full list of available configuration take a look at the TypoScript reference., (*15)

By default, the link target is set to _blank. If you want to override it, just define a custom link configuration parameter – either an empty string or a custom target/additional parameter configuration:, (*16)

renderingOptions:
  linkConfiguration:
    parameter: ''

Possible improvements or changes

Instead of creating a new form element, the existing Checkbox form element could have been extended. In order to provide a more complex example, the extension creates a new element., (*17)

At the time of writing this, you have to provide a small JavaScript snippet (see \Resources\Public\JavaScript\Backend\FormEditor\ViewModel.js). This snippet is needed to show the custom form element in the form editor. For future TYPO3 versions we are aiming to remove this stumbling block to smoothen the element registration., (*18)

Versions

News TYPO3 PHP Notes
master 11 - 12 7.4 - 8.2
4.x 11 - 12 7.4 - 8.2 Breaking changes. See comments below.
3.x 9 - 11 7.2 - 8.1 Breaking changes. See comments below.
2.x 9 - 11
1.x 8 - 9

Breaking changes version 4.x

Version 4.x includes the following breaking changes: * [!!!][TASK] Use timestamps as keys (1feab28) * [!!!][BUGFIX] Switch EXT:form hook to respect applied variants (543830b), (*19)

Breaking changes version 3.x

Version 3.x includes the following breaking changes: * [!!!][FEATURE] Move link resolving from field partial to hook (d128090) * [!!!][TASK] Drop deprecated hook usage (90695cf) * [!!!][TASK] Harden visibility and usage of FormElementLinkResolverHook (4ffb57b), (*20)

Credits

This TYPO3 extension was created by Björn Jacob and has been highly improved by Elias Häußler. The idea was born at the TYPO3 CertiFUNcation Day 2017. The audience of my talk kindly asked for such an element. Lightheaded, I said it will not take more than 30 minutes to create such an extension. Unfortunately, I could not make it in this time. It took my 1.5 hours to come up with the initial version code. The JS part gave me a hard time., (*21)

Thank you

Jochen Weiland - TYPOholic at jweiland.net - supported this challenge in multiple ways. Thanks for being an outstanding part of our TYPO3 community., (*22)

Elias Häußler - Best man, providing awesome PRs and providing the beautiful TYPO3 badges. Use them. Give him some kudos!, (*23)

The Versions

07/06 2018

dev-master

9999999-dev

  Sources   Download

GPL-2.0+

The Requires

 

by Björn Jacob TRITUM GmbH

06/06 2018

1.0.2

1.0.2.0

  Sources   Download

GPL-2.0+

The Requires

 

by Björn Jacob TRITUM GmbH