Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011
Upcoming SlideShare
Loading in...5
×
 

Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011

on

  • 1,626 views

Доклад познакомит начинающих друпалеров с идеологией, архитектурой и основами работы с формами в Drupal.

Доклад познакомит начинающих друпалеров с идеологией, архитектурой и основами работы с формами в Drupal.
<ul>
<li> элементы форм</li>
<li> валидация форм</li>
<li> действия (CallBack) форм</li>
<li> ahah действия (CallBack) форм</li>
<li> рендер форм</li>
<li> различия между Form API в Drupal 6 и 7</li>
<li> использование форм в собственных модулях</li>
<li> tips and tricks</li>
</ul>

Statistics

Views

Total Views
1,626
Slideshare-icon Views on SlideShare
984
Embed Views
642

Actions

Likes
0
Downloads
4
Comments
0

2 Embeds 642

http://camp11.drupal.ua 641
http://translate.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011 Oleksandr Masovets. Forms in Drupal. Drupal Camp Kyiv 2011 Presentation Transcript

    • Forms in Drupal Oleksandr Masovets E-mail: krasnyj@neformat.com.ua Skype: krasnyjdirex
    • Gold Sponsor ofDrupalCamp Kyiv 2011
    • Silver Sponsors ofDrupalCamp Kyiv 2011
    • Working with forms• Form – Render – System form• Form alter• Form validation• Form submit• Destination (redirect)
    • FormForm call function: drupal_get_form($form_id);•$form_id - the unique string identifying the desired form. If afunction with that name exists, it is called to build the form array.drupal_get_form() does the following:•Starts the entire form-building process by getting the $form fromthe builder function.•Translates the $form[name] items into actual form elements.•Performs any validation and "clean-up" that needs to be done, andcalls custom validation functions if declared.•Submits the form if a submit function is declared, and the form hasbeen submitted.•Calls any custom theming functions that have been declared.•Returns an HTML string which contains the actual form.
    • Form elements
    • Form element structureRequired parameters:$form[‘element name’] = array ( ‘#type’ = ‘element type’,);Every element automatically has these default values:•#description = NULL•#attributes = array()•#required = FALSE•#tree = FALSE•#parents = array()
    • AhahAjax callback for an element• Using ‘#ahah’(D6) or ‘#ajax’(D7) attributes to builds a form element with a set of #ahah#ajax properties.• Using ‘#ajax[‘callback’]’(D7) or ‘#ahah[‘path’]’(D6)#ajax[‘path’]’(D7) to locate ajax function.• Using additional ahahajax options to change behavior of the form element.
    • Theming forms• Adding #theme attributes to the form and/or elements.• Including any markup directly as an element in the $form array.• Break out any markup into a separate theme function.
    • Form alterPerform alterations before a form is rendered:hook_form_alter(&$form, &$form_state, $form_id); ORhook_form_FORM_ID_alter(&$form, &$form_state);
    • Form validation• Adding ‘#validate’ attribute (an array with list of custom validation functions) to the form.• Adding  ‘#element_validate’ attributes (an array with list of custom validation functions) to the form elements.• Using myform_validation($form, &$form_state) function.• The validation functions must use form_error() or form_set_error() functions to flag the element as having an error if the validation fails.
    • Form submit and redirect• Adding ‘#submit’ attribute (an array with list of custom submit functions) to the form.• Using myform_submit($form, &$form_state) function.• To determine where the user should be sent after the form is processed, the _submit function can place a path or URL in $form_state[redirect] which will be the target of a drupal_goto.• Every form is redirected after a submit. If nothing stored in $form_state[redirect], the form will simply be redirected to itself after a submit.
    • Links• http://api.drupal.org• http://api.drupal.org/api/drupal/develope r--topics--forms_api_reference.html/• http://drupal.org/node/751826
    • Forms in Drupal Oleksandr Masovets E-mail: krasnyj@neformat.com.ua Skype: krasnyjdirex