60 likes | 215 Views
Form API (FAPI). Intro to creating forms in a Drupal module. Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011. What is it?. Drupal provides a standard, easy to use, easy to extend and secure way of adding forms to your Drupal website: Form API or FAPI for short.
E N D
Form API (FAPI) Intro to creating forms in a Drupal module Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011
What is it? • Drupal provides a standard, easy to use, easy to extend and secure way of adding forms to your Drupal website: Form API or FAPI for short. Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011
Understanding FAPI • Scary looking code// First name $form['first_name'] = array( '#type' => 'textfield‘, '#title' => t('First Name'), '#required' => TRUE, '#description' => t('Please enter your First Name.'), ); • Lot's of nested arrays • Lot’s of documentation Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011
Who should use? • Module developers • If you plan to modify forms provided by other modules • If you want to create settings page for your module Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011
What you need? • http://drupal.org/project/examples • Sample module with: • Menu item – to create a page that displays form • Callback function – returns content for the page • _form – function with form array • _validate – form validation • _submit – handles form submission Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011
Thank you! :) Questions? Drupal Balkan Summit, Novi Sad 8 – 9 October, 2011