drupal. forms
TRANSCRIPT
![Page 1: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/1.jpg)
Drupal. Какая форма!
Какая динамика! Крайнюк Михаил
![Page 2: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/2.jpg)
![Page 3: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/3.jpg)
![Page 4: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/4.jpg)
![Page 5: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/5.jpg)
![Page 6: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/6.jpg)
![Page 7: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/7.jpg)
![Page 8: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/8.jpg)
![Page 9: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/9.jpg)
<form method="POST" name="login" action="http://site/log"> <div> Email </div> <div> <input type="text" name="email"> </div> <div> Пароль </div> <div> <input type="password" name="pass"> </div> <input type="submit" class="submit"> </form>
![Page 11: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/11.jpg)
Проверка данных
Если есть ошибки
Иначе обработка данных
![Page 12: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/12.jpg)
![Page 13: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/13.jpg)
function name_my_form($form, &$form_state) { $form[‘email'] = array( '#type' => ‘textfield', '#title' => t(‘Email'), ); $form[‘password'] = array( '#type' => ‘password', '#title' => t(‘Пароль'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t(‘Submit'), ); return $form; }
![Page 14: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/14.jpg)
Submit
Пароль
![Page 15: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/15.jpg)
function name_my_form_validate($form, &$form_state) { $values = &$form_state[‘values’]; $email = $values[‘email’]; $password = $values[‘password’]; ... (проверка почты и пароля) ... if ($error) { form_error($form[‘email’], t(‘Некорректная почта!’)); } }
function name_my_form_submit($form, $form_state) { ... (обработка данных) ... }
![Page 16: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/16.jpg)
![Page 17: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/17.jpg)
function mymodule_name_my_form_alter(&$form, &$form_state) {
$form['submit']['#value‘] = t(‘Войти'); }
Войти
Пароль
![Page 18: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/18.jpg)
‘#ajax’ => array( ‘callback’ => ‘my_callback’, ‘wrapper’ => ‘id-of-my-wrapper’, ‘method’ => ‘replace’, ‘effect’ => ‘fade’, ), AJAX
+ $commands[] + Drupal.ajax.prototype...
‘#states’ => array( ‘visible’ => ... ),
![Page 19: Drupal. Forms](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583e88cd8b42a2a4d8b4a1c/html5/thumbnails/19.jpg)
Спасибо за внимание!