ドラッグ可能なテーブルを作成し、その下に送信ボタンを追加しました。送信ボタンは表示できますが、送信ハンドラーが機能していません。以下はコードです。
function form_content_reorder($form, &$form_state)
{
$form = array();
$form['items'] = array();
$form['items']['#tree'] = TRUE;
$form['#theme'] = 'usercontentranking_reorder_form';
$form['name'] = array(
'#type' => 'item',
'#markup' => 'Hello '.get_genderval($user_data['gender']).$user_data['user_name'],);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Preferences'),
'#submit' => array('user_content_ranking_save'),);
return $form;
}
function usercontentranking_theme($existing, $type, $theme, $path) {
$themes = array(
'usercontentranking_reorder_form' => array(
'render element' => 'element'
),
);
return $themes;
}
function theme_usercontentranking_reorder_form($vars) {
$element = $vars['element'];
drupal_add_tabledrag('draggable_table', 'order', 'sibling', 'weight-group');
$header = array(
'label' => t(''),
'label2' => t(''),
'weight' => t('Weight'),
'operations' => t('Operations'),
);
$rows = array();
foreach (element_children($element['items']) as $key) {
$row = array();
$row['data'] = array();
$row['data'][] = drupal_render($element['items'][$key]['title']);
$row['data'][] = drupal_render($element['items'][$key]['user_fields']);
$row['data'][] = drupal_render($element['items'][$key]['weight']);
$row['data'][] = drupal_render($element['items'][$key]['operation']);
$row['class'] = array('draggable');
$rows[] = $row;
$themes = drupal_render($element['name']);
$themes .=theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array('id' => 'draggable_table'),
));
$themes .= drupal_render($element['submit']);
return $themes;
}
function user_content_ranking_save($form, &$form_state)
{
print "text";
}
行 $themes .= drupal_render($element['submit']); ボタンを表示できますが、関数 user_content_ranking_save が呼び出されていません。これで私を助けてください。