Form API 2.
Динамика
Крайнюк Михаил
Проверка данных
Если есть ошибки
Иначе обработка
данных
function name_my_form($form, &$form_state) {
…
return $form;
}
function name_my_form_validate(&$form, &$form_state) {
…
fo...
Form APIForm API
function name_my_form($form, &$form_state) {
$form[‘email'] = array(
'#type' => ‘textfield',
'#title' => ...
$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' =>...
#ajax
#ajax
#ajax
#ajax
ДАННЫЕ
ДАННЫЕ
ДАННЫЕ
ДАННЫЕ
$form['offer_type'] = array(
'#type' => ‘select',
'#title' => t('Select type of offer'),
'#options' => array( … ),
'#ajax'...
Спасибо за внимание!
Крайнюк Михаил
kraynuk.m@i20.biz
Динамика. Form API 2.
Upcoming SlideShare
Loading in …5
×

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

307 views

Published on

  • Be the first to comment

  • Be the first to like this

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

  1. 1. Form API 2. Динамика Крайнюк Михаил
  2. 2. Проверка данных Если есть ошибки Иначе обработка данных
  3. 3. 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']; }
  4. 4. Form APIForm API function name_my_form($form, &$form_state) { $form[‘email'] = array( '#type' => ‘textfield', '#title' => t(‘Email'), ); … return $form; }
  5. 5. $elements = drupal_get_form('name_my_form'); print render($elements);
  6. 6. . . .
  7. 7. #states | #ajax Form APIForm API
  8. 8. #states
  9. 9. #states
  10. 10. #states
  11. 11. #states#states $form['coupon_code'] = array( '#type' => ‘textfield', '#title' => t('Input number of coupon'), '#states' => array( 'visible' => array( ':input[name="abcde"]' => 'checked', ), ), );
  12. 12. #ajax
  13. 13. #ajax
  14. 14. #ajax
  15. 15. #ajax ДАННЫЕ ДАННЫЕ ДАННЫЕ ДАННЫЕ
  16. 16. $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
  17. 17. Спасибо за внимание! Крайнюк Михаил kraynuk.m@i20.biz

×