When I use button type for ajax, howto skip the validating msg ?


Drupal7 Form API 內建了 ajax 的功能
基本上要做出 JS 連動表單是沒問題的

這問題困擾了我好幾天
我想用 onclick 的方法把資料帶到另外一個表單
某些欄位是必填的
所以當 onlick 的時後 drupal 就會把要填的欄位都檢查一遍
他也會掃過 hook_validate
之前還因為這原因停用了 hook_validate
今天終於找到跳過 validate 的方式(validate 待真正 submit 再去驗證)
只要加入紅色的那行就可以囉!

$form['fb'] = array(
  '#type' => 'button',
  '#value' => 'Grab Facebook data into',
  '#ajax' => array(
    'callback' => 'ajax_fb_callback',
    'wrapper' => 'replacement',
    'method' => 'replaceWith',
  ),
  '#limit_validation_errors' => TRUE,
);


Comments

Popular posts from this blog

CentOS7 如何新增/移除 Rich Rule for firewalld

mac 安裝 mtr

Howto use Postman test Cors