Successfully reported this slideshow.

DrupalCamp 2011 -- Poutine Maker

1,479 views

Published on

My DrupalCamp 2011

Published in: Technology
  • Be the first to comment

  • Be the first to like this

DrupalCamp 2011 -- Poutine Maker

  1. 1. Poutine Maker: Custom Fields in Drupal 7 Tavish Armstrong tavish@evolvingweb.ca
  2. 2. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  3. 3. Resourceshttp://evolvingweb.ca/story/poutine-maker-introduction-field- api-drupal-7-part-1 http://drupal.org/sandbox/tarmstrong/1188140https://github.com/tarmstrong/poutine_maker
  4. 4. Custom fields: What are they?• Custom fields are like a custom data type• You can also have a custom widgets, formatters, validation
  5. 5. Custom Fields: What are they good for?• Drupal gives you text fields, date fields, etc.• It wont give you a colour field. Or a poutine field.• You may want multi-value with a fieldset.• Fancy widgets?• Fancy formatting?• Fancy validation?
  6. 6. Colour picker widget
  7. 7. Alternative: field_collectionExciting project!
  8. 8. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  9. 9. hook_field_info()
  10. 10. hook_field_widget_info()
  11. 11. hook_field_formatter_info()
  12. 12. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  13. 13. hook_field_widget_form()
  14. 14. hook_field_widget_form()
  15. 15. hook_field_widget_form()
  16. 16. hook_field_widget_form()
  17. 17. hook_field_widget_form()
  18. 18. hook_field_widget_form()
  19. 19. hook_field_widget_form()
  20. 20. hook_field_widget_form()
  21. 21. hook_field_is_empty()
  22. 22. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  23. 23. hook_field_schema()
  24. 24. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  25. 25. hook_field_widget_error()
  26. 26. hook_field_validate()
  27. 27. hook_field_widget_error()
  28. 28. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  29. 29. 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...);
  30. 30. hook_field_formatter_view()
  31. 31. poutine_maker_format_field()
  32. 32. poutine_maker_format_field()
  33. 33. poutine_maker_format_field()
  34. 34. The finished formatter
  35. 35. AgendaCustom fieldsWhat are they?What are they good for?Info() hooksCreating a widgetCreating a schemaCreating a validatorCreating a formatterDemo
  36. 36. Resourceshttp://evolvingweb.ca/story/poutine-maker-introduction-field- api-drupal-7-part-1 http://drupal.org/sandbox/tarmstrong/1188140https://github.com/tarmstrong/poutine_maker
  37. 37. Questions?Tavish Armstrong (tarmstrong) tavish@evolvingweb.ca

×