Drupal 7 - добавить свою кнопку в админку модуля - hook_form_alter drupal 7
Primary tabs
изучите данный пример:
/*эта функция выводит форму с настройками модуля*/
function lightmirror_form($form, &$form_state) {
$queryResult = nodes_to_text_file_retrieve_content_types();
$options = array();
while($record = $queryResult->fetchAssoc()) {
$options[$record['type']] = t($record['name']);
}
$form['nodestypes'] = array(
'#type' => 'checkboxes',
'#title' => t('Content types to include'),
'#default_value' => variable_get('nodes_to_text_file_content_types', array()),
'#description' => t('The content types to include.'),
'#options' => $options,
);
return system_settings_form($form);
}
/*
* а здесь мы добавим свою кнопку, которая вызовет
код функции your_module_ok() - или любой другой -
на наше усмотрение
*/
function lightmirror_form_alter(&$form, &$form_state) {
$form['nodestypes2'] = array(
'#type' => 'submit',
'#value' => 'Do action',
'#submit' => array('your_module_ok'),
);
}lightmirror - условное название модуля - на его месте по-идее должно быть название вашего модуля
- yii-primer's blog
- Log in to post comments
- 6444 reads