SlideShare a Scribd company logo
Poutine Maker: Custom Fields
         in Drupal 7
         Tavish Armstrong
      tavish@evolvingweb.ca
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
Resources


http://evolvingweb.ca/story/poutine-maker-introduction-field-
                     api-drupal-7-part-1

  http://drupal.org/sandbox/tarmstrong/1188140
https://github.com/tarmstrong/poutine_maker
Custom fields: What are they?


• Custom fields are like a custom data type
• You can also have a custom widgets, formatters, validation
Custom Fields: What are they good for?

• Drupal gives you text fields, date fields, etc.
• It won't give you a colour field. Or a poutine
  field.
• You may want multi-value with a fieldset.
• Fancy widgets?
• Fancy formatting?
• Fancy validation?
DrupalCamp 2011 -- Poutine Maker
Colour picker widget
Alternative: field_collection
Exciting project!
DrupalCamp 2011 -- Poutine Maker
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
hook_field_info()
hook_field_widget_info()
hook_field_formatter_info()
DrupalCamp 2011 -- Poutine Maker
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
hook_field_widget_form()
hook_field_widget_form()
hook_field_widget_form()
hook_field_widget_form()
hook_field_widget_form()
hook_field_widget_form()
hook_field_widget_form()
hook_field_widget_form()
DrupalCamp 2011 -- Poutine Maker
hook_field_is_empty()
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
hook_field_schema()
DrupalCamp 2011 -- Poutine Maker
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
hook_field_widget_error()
hook_field_validate()
hook_field_widget_error()
DrupalCamp 2011 -- Poutine Maker
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
hook_field_formatter_view()

• Take all the saved field items (i.e. each
  $delta) and return a renderable array for
  each

$element[0] = array( first poutine item ... );
$element[1] = array( second poutine item...);
hook_field_formatter_view()
poutine_maker_format_field()
poutine_maker_format_field()
poutine_maker_format_field()
The finished formatter
Agenda
Custom fields
What are they?
What are they good for?

Info() hooks

Creating a widget

Creating a schema

Creating a validator

Creating a formatter

Demo
Resources


http://evolvingweb.ca/story/poutine-maker-introduction-field-
                     api-drupal-7-part-1

  http://drupal.org/sandbox/tarmstrong/1188140
https://github.com/tarmstrong/poutine_maker
Questions?

Tavish Armstrong (tarmstrong)
   tavish@evolvingweb.ca

More Related Content

PPTX
Flutter 4
PDF
Creating a Responsive Drupal Theme: Presentation from DrupalCamp Montreal 2012
PDF
Site Building Checklist DrupalCamp Ottawa
PDF
Advanced Views Configuration: Presentation from DrupalCamp Montreal 2012
PDF
Instant Dynamic Forms with #states
PDF
Multilingual Content: Presentation from DrupalCamp Montreal 2012
PDF
Drupal 7 for Government Case Study: Presentation at DrupalCamp Montreal 2012
KEY
Views Configuration at Drupal Camp Toronto 2012
Flutter 4
Creating a Responsive Drupal Theme: Presentation from DrupalCamp Montreal 2012
Site Building Checklist DrupalCamp Ottawa
Advanced Views Configuration: Presentation from DrupalCamp Montreal 2012
Instant Dynamic Forms with #states
Multilingual Content: Presentation from DrupalCamp Montreal 2012
Drupal 7 for Government Case Study: Presentation at DrupalCamp Montreal 2012
Views Configuration at Drupal Camp Toronto 2012

Viewers also liked (9)

PDF
PDF
Introduction to the Drupal - Web Experience Toolkit
PDF
Upgrading to Drupal 8: Benefits and Gotchas
PDF
Using Core Themes in Drupal 8
KEY
Multilingual Site Building with Drupal 7 at Drupal Camp NYC 10
PDF
Responsive Design in Drupal with Zen and Zen Grids
PDF
What is Drupal? An Introduction to Drupal 8
PDF
Managing Translation Workflows in Drupal 7
PDF
Meilleures pratiques pour construire un site web Drupal
Introduction to the Drupal - Web Experience Toolkit
Upgrading to Drupal 8: Benefits and Gotchas
Using Core Themes in Drupal 8
Multilingual Site Building with Drupal 7 at Drupal Camp NYC 10
Responsive Design in Drupal with Zen and Zen Grids
What is Drupal? An Introduction to Drupal 8
Managing Translation Workflows in Drupal 7
Meilleures pratiques pour construire un site web Drupal
Ad

Similar to DrupalCamp 2011 -- Poutine Maker (8)

KEY
Custom Field Formatters
KEY
Fields in Core: How to create a custom field
PDF
Field formatters
PDF
Drupal developer days 2011 custom formatters
KEY
Pure Sign Breakfast Presentations - Drupal FieldAPI
ODP
The Waminals Project
ODP
Drupal: code complexity
PDF
Introduction to Drupal 7 - Content types and fields
Custom Field Formatters
Fields in Core: How to create a custom field
Field formatters
Drupal developer days 2011 custom formatters
Pure Sign Breakfast Presentations - Drupal FieldAPI
The Waminals Project
Drupal: code complexity
Introduction to Drupal 7 - Content types and fields
Ad

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Diabetes mellitus diagnosis method based random forest with bat algorithm
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation_ Review paper, used for researhc scholars
Spectral efficient network and resource selection model in 5G networks
CIFDAQ's Market Insight: SEC Turns Pro Crypto
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Chapter 3 Spatial Domain Image Processing.pdf

DrupalCamp 2011 -- Poutine Maker