Динамика. form api 2

Post on 30-Jun-2015

86 Views

Category:

Presentations & Public Speaking

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Form API 2.Динамика

Крайнюк Михаил

Проверка данных

Если есть ошибки

Иначе обработкаданных

function name_my_form($form, &$form_state) { … return $form;}

function name_my_form_validate(&$form, &$form_state) { … form_error($form['bad_item'], t('Nope...'));}

function name_my_form_submit(&$form, &$form_state) { … $a = $form_state['values']['good_item'];}

Form APIForm API

function name_my_form($form, &$form_state) { $form[‘email'] = array( '#type' => ‘textfield', '#title' => t(‘Email'), ); … return $form;}

$elements = drupal_get_form('name_my_form');

print render($elements);

. . .

#states | #ajax

Form APIForm API

#states

#states

#states

#states#states$form['coupon_code'] = array( '#type' => ‘textfield', '#title' => t('Input number of coupon'), '#states' => array( 'visible' => array( ':input[name="abcde"]' => 'checked', ), ),);

#ajax

#ajax

#ajax

#ajax

ДАННЫЕ

ДАННЫЕ

ДАННЫЕ

ДАННЫЕ

$form['offer_type'] = array( '#type' => ‘select', '#title' => t('Select type of offer'), '#options' => array( … ), '#ajax' => array( 'callback' => 'name_of_your_php_function', 'wrapper' => 'html-id-of-wrapper', 'method' => 'replace', 'effect' => 'fade', ),);

#ajax

Спасибо за внимание!

Крайнюк Михаил

kraynuk.m@i20.biz

top related