Bug #82248
closedError class is not set on input fields
Added by Frederik Holz about 7 years ago. Updated over 6 years ago.
0%
Description
While working with the new Form Framework i noticed that the error class is not set on the input field. I reverted all my changes to get a clean Form and even then, the error class is not set when I send an empty form (just simple fields like text, radio, checkbox etc.)
Validation results however are set (like the error message or the "has-errors" class.
Updated by Mathias Brodala about 7 years ago
Can you elaborate on your usecase and post your form definition?
You say that you see the has-errors
class which means you must have added at least one validator which failed for the given input as expected. There are no additional classes set on the input field itself by default. You can however override the default templates/partials to change this.
Updated by Mathias Brodala about 7 years ago
- Status changed from New to Needs Feedback
Updated by Frederik Holz about 7 years ago
Hello Mathias,
Thanks for the response!
I did not know, that per default there are no error classes. I used simple Textfields in the FormEditor with the required checkbox checked.
I Tested it without my own Setup.yml as well es with it.
My BaseSetup.yml looks like this
TYPO3:
CMS:
Form:
persistenceManager:
allowedExtensionPaths:
20: 'EXT:extend/Resources/Private/Forms/'
allowSaveToExtensionPaths: true
prototypes:
standard:
formElementsDefinition:
Form:
renderingOptions:
templateRootPaths:
20: 'EXT:extend/Resources/Private/Templates/Form/'
partialRootPaths:
20: 'EXT:extend/Resources/Private/Partials/Form/'
layoutRootPaths:
20: 'EXT:extend/Resources/Private/Layouts/Form/'
translation:
translationFile:
# translation files for the frontend
10: 'EXT:form/Resources/Private/Language/locallang.xlf'
20: 'EXT:extend/Resources/Private/Language/locallang.xlf'
########### MIXINS ###########
mixins:
########### FORM ELEMENT MIXINS ###########
formElementMixins:
FormElementMixin:
properties:
containerClassAttribute: 'form-items'
elementClassAttribute: 'input-style100'
elementErrorClassAttribute: 'error'
I did not override the Default Text.html file in my extend Extension. containerClassAttribute as well as elementClassAttribute are set.
I thought, that elementErrorClassAttribute is set as error class for fluid inputs. As seen here in the default Text.html of the Form Extension:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">
<formvh:renderRenderable renderable="{element}">
<f:render partial="Field/Field" arguments="{element: element}" contentAs="elementContent">
<f:form.textfield
property="{element.identifier}"
id="{element.uniqueIdentifier}"
class="{element.properties.elementClassAttribute} form-control"
errorClass="{element.properties.elementErrorClassAttribute}"
additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}"
/>
</f:render>
</formvh:renderRenderable>
</html>
Just for clarity here a simple form definition I used:
renderingOptions:
submitButtonLabel: Submit
identifier: contact
label: 'Conctact form'
type: Form
prototypeName: standard
finishers:
-
options:
subject: 'Contact Request'
recipientAddress: my@mail.com
recipientName: 'My Name'
senderAddress: noreply@mail.de
senderName: Test
replyToAddress: ''
carbonCopyAddress: ''
blindCarbonCopyAddress: ''
format: html
attachUploads: 'true'
translation:
language: ''
identifier: EmailToReceiver
-
options:
pageUid: '71'
additionalParameters: ''
identifier: Redirect
renderables:
-
renderingOptions:
previousButtonLabel: ''
nextButtonLabel: ''
identifier: page-1
label: ''
type: Page
renderables:
-
type: Fieldset
identifier: fieldset-1
label: ''
renderables:
-
properties:
options:
2: 'Marine, Power'
3: 'Process, Water'
4: 'Turbines, compressors, generators'
5: After-Sales-Service
fluidAdditionalAttributes:
required: required
type: SingleSelect
identifier: contact-select
label: Contact
defaultValue: '2'
validators:
-
identifier: NotEmpty
-
defaultValue: ''
identifier: firstname
label: Firstname
type: Text
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
type: Text
identifier: surname
label: Surname
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
identifier: company
label: Company
type: Text
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
identifier: position
label: Position
type: Text
-
defaultValue: ''
type: Text
identifier: street-no
label: 'Street / No'
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
type: Text
identifier: zip
label: Zip
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
type: Text
identifier: city
label: City
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
type: Text
identifier: phone
label: 'Phone number'
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: NotEmpty
-
defaultValue: ''
type: Text
identifier: email
label: E-Mail
properties:
fluidAdditionalAttributes:
required: required
validators:
-
identifier: EmailAddress
-
identifier: NotEmpty
-
defaultValue: ''
identifier: message
label: Message
type: Textarea
properties:
fluidAdditionalAttributes:
placeholder: ''
required: required
validators:
-
identifier: NotEmpty
Hope this helps.
Updated by Björn Jacob about 7 years ago
- Status changed from Needs Feedback to New
We will check again.
Updated by Ralf Zimmermann over 6 years ago
- Has duplicate Bug #82093: Form Viewhelpers: Attribute errorClass not working added