Skip to content

Commit

Permalink
Merge pull request #8 from sitegeist/feature/showCustomErrorMessageIn…
Browse files Browse the repository at this point in the history
…ClientValidation

FEATURE: Use custom error message for client validation
  • Loading branch information
mficzel authored Aug 31, 2023
2 parents b987e6e + 19650b6 commit ef3f513
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions NodeTypes/Field/CheckBoxes/CheckBoxes.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ prototype(Sitegeist.PaperTiger:Field.CheckBoxes) < prototype(Neos.Neos:ContentCo
<label>
<Neos.Fusion.Form:Checkbox
field.value={option.value}
attributes.required={props.isRequired}
/> {option.label || option.value}
</label>
</div>
Expand Down
6 changes: 6 additions & 0 deletions NodeTypes/Field/Date/Date.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ prototype(Sitegeist.PaperTiger:Field.Date) < prototype(Neos.Neos:ContentComponen
isRequired = ${q(node).property('isRequired')}
earliestDate = ${q(node).property('earliestDate')}
latestDate = ${q(node).property('latestDate')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -16,6 +18,10 @@ prototype(Sitegeist.PaperTiger:Field.Date) < prototype(Neos.Neos:ContentComponen
attributes.placeholder={props.placeholder}
attributes.min={props.earliestDate ? Date.format(props.earliestDate, 'Y-m-d') : false}
attributes.max={props.latestDate ? Date.format(props.latestDate, 'Y-m-d') : false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down
7 changes: 7 additions & 0 deletions NodeTypes/Field/Dropdown/Dropdown.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ prototype(Sitegeist.PaperTiger:Field.Dropdown) < prototype(Neos.Neos:ContentComp
emptyLabel = ${q(node).property('emptyLabel')}
emptyOptionEnabled = ${q(node).property('emptyOptionEnabled')}

customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
field.name={props.name}
Expand All @@ -16,6 +19,10 @@ prototype(Sitegeist.PaperTiger:Field.Dropdown) < prototype(Neos.Neos:ContentComp
>
<Neos.Fusion.Form:Select
attributes.required={props.isRequired}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
>
<Neos.Fusion.Form:Select.Option option.value="" attributes.label={props.emptyLabel} @if={props.emptyOptionEnabled} />
<Neos.Fusion:Loop items={props.options} itemName="item">
Expand Down
7 changes: 7 additions & 0 deletions NodeTypes/Field/Email/Email.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ prototype(Sitegeist.PaperTiger:Field.Email) < prototype(Neos.Neos:ContentCompone
label = ${q(node).property('label')}
placeholder = ${q(node).property('placeholder')}
isRequired = ${q(node).property('isRequired')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -13,6 +15,11 @@ prototype(Sitegeist.PaperTiger:Field.Email) < prototype(Neos.Neos:ContentCompone
attributes.type="email"
attributes.required={props.isRequired}
attributes.placeholder={props.placeholder || false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}

/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down
6 changes: 6 additions & 0 deletions NodeTypes/Field/Number/Number.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ prototype(Sitegeist.PaperTiger:Field.Number) < prototype(Neos.Neos:ContentCompon
isRequired = ${q(node).property('isRequired')}
minimumValue = ${q(node).property('minimumValue')}
maximumValue = ${q(node).property('maximumValue')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -17,6 +19,10 @@ prototype(Sitegeist.PaperTiger:Field.Number) < prototype(Neos.Neos:ContentCompon
attributes.placeholder={props.placeholder || false}
attributes.min={props.minimumValue ? props.minimumValue : false}
attributes.max={props.minimumValue ? props.maximumValue : false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down
1 change: 1 addition & 0 deletions NodeTypes/Field/RadioButtons/RadioButtons.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ prototype(Sitegeist.PaperTiger:Field.RadioButtons) < prototype(Neos.Neos:Content
<label>
<Neos.Fusion.Form:Radio
field.value={option.value}
attributes.required={props.isRequired}
/> {option.label}
</label>
</div>
Expand Down
6 changes: 6 additions & 0 deletions NodeTypes/Field/Slider/Slider.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ prototype(Sitegeist.PaperTiger:Field.Slider) < prototype(Neos.Neos:ContentCompon
minimumValue = ${q(node).property('minimumValue')}
maximumValue = ${q(node).property('maximumValue')}
stepValue = ${q(node).property('stepValue')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -19,6 +21,10 @@ prototype(Sitegeist.PaperTiger:Field.Slider) < prototype(Neos.Neos:ContentCompon
attributes.min={Type.isInteger(props.minimumValue) ? props.minimumValue : false}
attributes.max={Type.isInteger(props.maximumValue) ? props.maximumValue : false}
attributes.step={Type.isInteger(props.stepValue) ? props.stepValue : false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down
6 changes: 6 additions & 0 deletions NodeTypes/Field/TelephoneNumber/TelephoneNumber.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ prototype(Sitegeist.PaperTiger:Field.TelephoneNumber) < prototype(Neos.Neos:Cont
label = ${q(node).property('label')}
placeholder = ${q(node).property('placeholder')}
isRequired = ${q(node).property('isRequired')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -13,6 +15,10 @@ prototype(Sitegeist.PaperTiger:Field.TelephoneNumber) < prototype(Neos.Neos:Cont
attributes.type="tel"
attributes.required={props.isRequired}
attributes.placeholder={props.placeholder || false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down
6 changes: 6 additions & 0 deletions NodeTypes/Field/Text/MultiLine/MultiLine.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ prototype(Sitegeist.PaperTiger:Field.Text.MultiLine) < prototype(Neos.Neos:Conte
maximumLength = ${q(node).property('maximumLength')}
regularExpression = ${q(node).property('regularExpression')}
lineNumber = ${q(node).property('lineNumber')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -20,6 +22,10 @@ prototype(Sitegeist.PaperTiger:Field.Text.MultiLine) < prototype(Neos.Neos:Conte
attributes.pattern={props.regularExpression || false}
attributes.placeholder={props.placeholder || false}
attributes.rows={props.lineNumber || false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down
6 changes: 6 additions & 0 deletions NodeTypes/Field/Text/SingleLine/SingleLine.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ prototype(Sitegeist.PaperTiger:Field.Text.SingleLine) < prototype(Neos.Neos:Cont
minimumLength = ${q(node).property('minimumLength')}
maximumLength = ${q(node).property('maximumLength')}
regularExpression = ${q(node).property('regularExpression')}
customErrorMessageEnabled = ${q(node).property('customErrorMessageEnabled')}
customErrorMessage = ${q(node).property('customErrorMessage')}

renderer = afx`
<Sitegeist.PaperTiger:FieldContainer
Expand All @@ -18,6 +20,10 @@ prototype(Sitegeist.PaperTiger:Field.Text.SingleLine) < prototype(Neos.Neos:Cont
attributes.maxlength={props.maximumLength || false}
attributes.pattern={props.regularExpression || false}
attributes.placeholder={props.placeholder || false}
attributes.oninvalid={"this.setCustomValidity('" + props.customErrorMessage + "')"}
attributes.oninvalid.@if={props.customErrorMessageEnabled}
attributes.oninput={"this.setCustomValidity('')"}
attributes.oninput.@if={props.customErrorMessageEnabled}
/>
</Sitegeist.PaperTiger:FieldContainer>
`
Expand Down

0 comments on commit ef3f513

Please sign in to comment.