Skip to content

Commit

Permalink
Merge pull request #97 from neos/feature/addContactFormBasedOnFusionF…
Browse files Browse the repository at this point in the history
…orms

FEATURE:  Add ContactForm NodeType based on the Neos.Fusion.Form package

This change adds a very basic ContactForm NodeType based on Neos.Fusion.Forms. https://github.com/neos/fusion-form

The content still mentions the fusion.form framework alongside neos.fusion.form but the content o the form page is now a fusion form with inspector settings.
  • Loading branch information
mficzel authored Apr 16, 2021
2 parents 9168305 + ff2391f commit 7097e47
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 159 deletions.
79 changes: 79 additions & 0 deletions Configuration/NodeTypes.Content.ContactForm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
##
# A very simple "contactForm" nodetype based on the Neos.Fusion.Form package
#
'Neos.Demo:Content.ContactForm':
superTypes:
'Neos.Neos:Content': true
'Neos.Demo:Constraint.Content.Column': true
ui:
label: i18n
icon: 'icon-envelope'
inspector:
groups:
email:
label: i18n
icon: envelope
tab: default
redirect:
label: i18n
icon: share
tab: default
message:
label: i18n
icon: comment
tab: default
properties:
subject:
type: string
defaultValue: ''
ui:
label: i18n
inspector:
group: email
recipientName:
type: string
defaultValue: ''
ui:
label: i18n
inspector:
group: email
recipientAddress:
type: string
defaultValue: ''
ui:
label: i18n
inspector:
group: email
senderName:
type: string
defaultValue: ''
ui:
label: i18n
inspector:
group: email
senderAddress:
type: string
defaultValue: ''
ui:
label: i18n
inspector:
group: email
redirect:
type: reference
defaultValue: null
ui:
label: i18n
inspector:
group: redirect
editorOptions:
nodeTyps: ['Neos.Neos:Document']
message:
type: string
defaultValue: ''
ui:
label: i18n
inspector:
group: message
editor: 'Neos.Neos/Inspector/Editors/TextAreaEditor'
editorOptions:
rows: 7
14 changes: 0 additions & 14 deletions Configuration/NodeTypes.Override.Neos.NodeTypes.Form.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ Neos:
flickr:
tagStreamUriPattern: 'http://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=%s'
userStreamUriPattern: 'http://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&id=%s'
Form:
yamlPersistenceManager:
savePath: 'resource://Neos.Demo/Private/Form/'
presets:
bootstrap:
title: 'Twitter bootstrap'
parentPreset: default
formElementTypes:
'Neos.Form:Base':
renderingOptions:
layoutPathPattern: 'resource://Neos.Demo/Private/Templates/ContactForm/{@type}.html'
'Neos.Form:FormElement':
properties:
elementClassAttribute: form-control
'Neos.Form:MultiLineText':
properties:
elementClassAttribute: form-control
Neos:
userInterface:
editPreviewModes:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
90 changes: 48 additions & 42 deletions Resources/Private/Content/Sites.xml

Large diffs are not rendered by default.

58 changes: 0 additions & 58 deletions Resources/Private/Form/contact-form.yaml

This file was deleted.

73 changes: 73 additions & 0 deletions Resources/Private/Fusion/Content/ContactForm.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
##
# "ContactForm" element
#
prototype(Neos.Demo:Content.ContactForm) < prototype(Neos.Neos:ContentComponent) {

renderer = Neos.Fusion.Form:Runtime.RuntimeForm {
namespace = 'contact'
process {
content = afx`
<fieldset>
<legend>Contact</legend>
<Neos.Fusion.Form:FieldContainer label="Name" field.name="name" attributes.class="form-group clearfix">
<div class="input">
<Neos.Fusion.Form:Input attributes.class="form-control" />
</div>
</Neos.Fusion.Form:FieldContainer>
<Neos.Fusion.Form:FieldContainer label="Email" field.name="email" attributes.class="form-group clearfix">
<div class="input">
<Neos.Fusion.Form:Input attributes.class="form-control" />
</div>
</Neos.Fusion.Form:FieldContainer>
<Neos.Fusion.Form:FieldContainer label="Message" field.name="message" attributes.class="form-group clearfix">
<div class="input">
<Neos.Fusion.Form:Textarea attributes.class="form-control" />
</div>
</Neos.Fusion.Form:FieldContainer>
</fieldset>
`

footer = afx`
<button type="submit" class="btn btn-primary">Submit</button>
`

schema {
name = ${Form.Schema.string().isRequired()}
email = ${Form.Schema.string().isRequired().validator('EmailAddress')}
message = ${Form.Schema.string().isRequired()}
}
}

action {
message {
type = 'Neos.Fusion.Form.Runtime:Message'
options.message = ${q(node).property('message')}
}

email {
@if.has = ${q(node).property('subject') && q(node).property('recipientAddress') && q(node).property('senderAddress')}
type = 'Neos.Fusion.Form.Runtime:Email'
options {
recipientName = ${q(node).property('recipientName')}
recipientAddress = ${q(node).property('recipientAddress')}
senderName = ${q(node).property('senderName')}
senderAddress = ${q(node).property('senderAddress')}
replyToAddress = ${data.email}
subject = ${q(node).property('subject')}
html = afx`
<p>Message from {data.name}</p>
<p>{data.message}</p>
`
}
}

redirect {
@if.has = ${q(node).property('redirect')}
type = 'Neos.Fusion.Form.Runtime:Redirect'
options.uri = Neos.Neos:NodeUri {
node = ${q(node).property('redirect')}
}
}
}
}
}
7 changes: 0 additions & 7 deletions Resources/Private/Templates/ContactForm/Email.txt

This file was deleted.

20 changes: 0 additions & 20 deletions Resources/Private/Templates/ContactForm/Field.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="" product-name="Neos.Demo" source-language="en" datatype="plaintext">
<body>
<trans-unit id="ui.label" xml:space="preserve">
<source>Contact Form</source>
</trans-unit>
<trans-unit id="groups.message" xml:space="preserve">
<source>Message</source>
</trans-unit>
<trans-unit id="groups.email" xml:space="preserve">
<source>EMail</source>
</trans-unit>
<trans-unit id="groups.redirect" xml:space="preserve">
<source>Redirect</source>
</trans-unit>
<trans-unit id="properties.message" xml:space="preserve">
<source>Message after submit</source>
</trans-unit>
<trans-unit id="properties.redirect" xml:space="preserve">
<source>Redirect after submit</source>
</trans-unit>
<trans-unit id="properties.recipientName" xml:space="preserve">
<source>Recipient name</source>
</trans-unit>
<trans-unit id="properties.recipientAddress" xml:space="preserve">
<source>Recipient email address</source>
</trans-unit>
<trans-unit id="properties.senderName" xml:space="preserve">
<source>Sender name</source>
</trans-unit>
<trans-unit id="properties.senderAddress" xml:space="preserve">
<source>Sender email address</source>
</trans-unit>
<trans-unit id="properties.subject" xml:space="preserve">
<source>Subject</source>
</trans-unit>
</body>
</file>
</xliff>
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"neos/nodetypes-basemixins": "*",
"neos/nodetypes-assetlist": "*",
"neos/nodetypes-contentreferences": "*",
"neos/nodetypes-form": "*",
"neos/nodetypes-html": "*",
"neos/nodetypes-navigation": "*",
"flowpack/neos-frontendlogin": "^4.0"
Expand Down

0 comments on commit 7097e47

Please sign in to comment.