SlideShare ist ein Scribd-Unternehmen logo
1 von 9
A modular approach to Forms
13 July 2015 • SilverStripe London • Dan Hensby
Why modular forms?
● Keep related logic in one place
● Have a single point of truth for forms
● Form re-use is easy
● Add logic to all forms in one go
● Remove logic from your controller
● Provide a common interface for defining forms in you project
Here we are:
● Defining an abstract class to create
our common interface
● Making most constructor arguments
optional
● Using internal class methods to define
Fields, Actions & Validator
Now we have a common API for creating
forms
A base form
Defining an interface and API for your forms
Here we are:
● Defining a simple contact form
● Adding fields
● Setting the button label
● Making the fields required
● Defining the submission handler `doSubmit`
● Using `Config` to assign defaults for the outgoing
email
Creating a contact form
We’ve defined a simple Email
Template for contact form
submissions
Create a simple email template
We’ve all done this before
Here we have:
● Added `Form` and `success` as “allowed
action”
● Defined a `Form` method to create the
`ContactForm`
● Defined a `success` action on the
controller (and template)
We have removed the logic around the
`ContactForm` from the controller
Set up the controller
● Since 3.0 styling form fields has become simple
● We can add custom template files to override the
markup
● We can work around default behaviour of duplicated
classnames
● In 3.2 we can add default class names to forms and
fields
Styling the front end form
● Using BEM to write clear CSS
● Block Element Modifier
● .block .block__element .block__element--modifier
● Best used with a CSS pre-processor
● Solves many common issues with
CSS on (large) projects
Resources:
● https://en.bem.info/
● http://cssguidelin.es/
Creating simple CSS
Thank you!
Code here: http://bit.ly/ss3forms
Twitter/GitHub/etc: @dhensby

Weitere ähnliche Inhalte

Andere mochten auch

Open It, Read It, Buy It Email Marketing with the AppExchange
Open It, Read It, Buy It Email Marketing with the AppExchangeOpen It, Read It, Buy It Email Marketing with the AppExchange
Open It, Read It, Buy It Email Marketing with the AppExchange
dreamforce2006
 
Manual daniel ponce
Manual daniel ponceManual daniel ponce
Manual daniel ponce
MoreePonce
 
plan evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...
plan  evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...plan  evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...
plan evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...
Michel Cassiani
 
O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13
O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13
O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13
Diego Fortunatto
 

Andere mochten auch (19)

E-mail
E-mailE-mail
E-mail
 
Tradersecrets14
Tradersecrets14Tradersecrets14
Tradersecrets14
 
Build booming mindset
Build booming mindsetBuild booming mindset
Build booming mindset
 
Mapa metro
Mapa metroMapa metro
Mapa metro
 
Open It, Read It, Buy It Email Marketing with the AppExchange
Open It, Read It, Buy It Email Marketing with the AppExchangeOpen It, Read It, Buy It Email Marketing with the AppExchange
Open It, Read It, Buy It Email Marketing with the AppExchange
 
14 15
14 1514 15
14 15
 
Manual daniel ponce
Manual daniel ponceManual daniel ponce
Manual daniel ponce
 
2005_matzon
2005_matzon2005_matzon
2005_matzon
 
Grupo mota
Grupo motaGrupo mota
Grupo mota
 
plan evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...
plan  evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...plan  evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...
plan evaluacion bajo el enfoque conductista, contructivista y contexto ecolo...
 
Observatorio de Clima Emprendedor 2012
Observatorio de Clima Emprendedor 2012Observatorio de Clima Emprendedor 2012
Observatorio de Clima Emprendedor 2012
 
TRACCIÓN CADENA SUMINISTRO: COMPRA PRIVADA VERDE, INTRODUCCIÓN DE CRITERIOS A...
TRACCIÓN CADENA SUMINISTRO: COMPRA PRIVADA VERDE, INTRODUCCIÓN DE CRITERIOS A...TRACCIÓN CADENA SUMINISTRO: COMPRA PRIVADA VERDE, INTRODUCCIÓN DE CRITERIOS A...
TRACCIÓN CADENA SUMINISTRO: COMPRA PRIVADA VERDE, INTRODUCCIÓN DE CRITERIOS A...
 
Software One Corporativa
Software One Corporativa Software One Corporativa
Software One Corporativa
 
Pasos para lograr una buena salud financiera empresarial
Pasos para lograr una buena salud financiera empresarialPasos para lograr una buena salud financiera empresarial
Pasos para lograr una buena salud financiera empresarial
 
Beacons
BeaconsBeacons
Beacons
 
hydraulic power solution faridabad , cnc solution
hydraulic power solution faridabad , cnc solutionhydraulic power solution faridabad , cnc solution
hydraulic power solution faridabad , cnc solution
 
Estilo de dirección orientativo. Dar visión estratégica al equipo.
Estilo de dirección orientativo. Dar visión estratégica al equipo. Estilo de dirección orientativo. Dar visión estratégica al equipo.
Estilo de dirección orientativo. Dar visión estratégica al equipo.
 
O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13
O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13
O chifre pequeno de daniel 7 e a primeira besta de apocalipse 13
 
Studying Migrations Routes: New data and Tools
Studying Migrations Routes: New data and ToolsStudying Migrations Routes: New data and Tools
Studying Migrations Routes: New data and Tools
 

Ähnlich wie Modular forms in SilverStripe 3

Web Development and Design Final ProjectBefore you begin the p.docx
Web Development and Design Final ProjectBefore you begin the p.docxWeb Development and Design Final ProjectBefore you begin the p.docx
Web Development and Design Final ProjectBefore you begin the p.docx
melbruce90096
 

Ähnlich wie Modular forms in SilverStripe 3 (20)

Data analysis with Postgres and Power BI
Data analysis with Postgres and Power BIData analysis with Postgres and Power BI
Data analysis with Postgres and Power BI
 
PDF in Lotus Notes applications
PDF in Lotus Notes applicationsPDF in Lotus Notes applications
PDF in Lotus Notes applications
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Managing requirements with user stories
Managing requirements with user storiesManaging requirements with user stories
Managing requirements with user stories
 
Industrail training report on website design and development
Industrail training report on website design and developmentIndustrail training report on website design and development
Industrail training report on website design and development
 
aCtive Collabs in Quick Review
aCtive Collabs in Quick ReviewaCtive Collabs in Quick Review
aCtive Collabs in Quick Review
 
Workday Integration Online Training.pdf
Workday Integration Online Training.pdfWorkday Integration Online Training.pdf
Workday Integration Online Training.pdf
 
Intuit Quickbase Empower 2015 - Finish Strong: SUCCESSFULLLY ROLLING OUT YOUR...
Intuit Quickbase Empower 2015 - Finish Strong: SUCCESSFULLLY ROLLING OUT YOUR...Intuit Quickbase Empower 2015 - Finish Strong: SUCCESSFULLLY ROLLING OUT YOUR...
Intuit Quickbase Empower 2015 - Finish Strong: SUCCESSFULLLY ROLLING OUT YOUR...
 
Web Development and Design Final ProjectBefore you begin the p.docx
Web Development and Design Final ProjectBefore you begin the p.docxWeb Development and Design Final ProjectBefore you begin the p.docx
Web Development and Design Final ProjectBefore you begin the p.docx
 
MuleSoftMeetup-B2BIntegrations_using_MuleSoft
MuleSoftMeetup-B2BIntegrations_using_MuleSoftMuleSoftMeetup-B2BIntegrations_using_MuleSoft
MuleSoftMeetup-B2BIntegrations_using_MuleSoft
 
Finish Strong -- Successfully Rolling Out Your Killer QuickBase App
Finish Strong -- Successfully Rolling Out Your Killer QuickBase AppFinish Strong -- Successfully Rolling Out Your Killer QuickBase App
Finish Strong -- Successfully Rolling Out Your Killer QuickBase App
 
SharePoint 2013 Workflows
SharePoint 2013 WorkflowsSharePoint 2013 Workflows
SharePoint 2013 Workflows
 
Mail Merge with Lotus Notes
Mail Merge with Lotus NotesMail Merge with Lotus Notes
Mail Merge with Lotus Notes
 
Benchmarking new
Benchmarking newBenchmarking new
Benchmarking new
 
Workflow for XPages
Workflow for XPagesWorkflow for XPages
Workflow for XPages
 
ML, Statistics, and Spark with Databricks for Maximizing Revenue in a Delayed...
ML, Statistics, and Spark with Databricks for Maximizing Revenue in a Delayed...ML, Statistics, and Spark with Databricks for Maximizing Revenue in a Delayed...
ML, Statistics, and Spark with Databricks for Maximizing Revenue in a Delayed...
 
Mail Merge with Lotus Notes
Mail Merge with Lotus NotesMail Merge with Lotus Notes
Mail Merge with Lotus Notes
 
Link your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdfLink your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdf
 
SharePoint 2013 Workflow from K2
SharePoint 2013 Workflow from K2SharePoint 2013 Workflow from K2
SharePoint 2013 Workflow from K2
 
SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
 

Kürzlich hochgeladen

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 

Modular forms in SilverStripe 3

  • 1. A modular approach to Forms 13 July 2015 • SilverStripe London • Dan Hensby
  • 2. Why modular forms? ● Keep related logic in one place ● Have a single point of truth for forms ● Form re-use is easy ● Add logic to all forms in one go ● Remove logic from your controller ● Provide a common interface for defining forms in you project
  • 3. Here we are: ● Defining an abstract class to create our common interface ● Making most constructor arguments optional ● Using internal class methods to define Fields, Actions & Validator Now we have a common API for creating forms A base form Defining an interface and API for your forms
  • 4. Here we are: ● Defining a simple contact form ● Adding fields ● Setting the button label ● Making the fields required ● Defining the submission handler `doSubmit` ● Using `Config` to assign defaults for the outgoing email Creating a contact form
  • 5. We’ve defined a simple Email Template for contact form submissions Create a simple email template We’ve all done this before
  • 6. Here we have: ● Added `Form` and `success` as “allowed action” ● Defined a `Form` method to create the `ContactForm` ● Defined a `success` action on the controller (and template) We have removed the logic around the `ContactForm` from the controller Set up the controller
  • 7. ● Since 3.0 styling form fields has become simple ● We can add custom template files to override the markup ● We can work around default behaviour of duplicated classnames ● In 3.2 we can add default class names to forms and fields Styling the front end form
  • 8. ● Using BEM to write clear CSS ● Block Element Modifier ● .block .block__element .block__element--modifier ● Best used with a CSS pre-processor ● Solves many common issues with CSS on (large) projects Resources: ● https://en.bem.info/ ● http://cssguidelin.es/ Creating simple CSS
  • 9. Thank you! Code here: http://bit.ly/ss3forms Twitter/GitHub/etc: @dhensby