开发者

Drupal - how to disable "Input Format" fieldset in node edit form

I am using hook_form_alter to disable some publishing options whet authors adds or edits the nodes:

/**
 * hook_form_alter ()
 */
function mymodule_form_alter(&$form, $form_state, $form_id) {
  global $user;

if ($form['#id'] == 'node-form') {

    unset($form['comment_settings']);
    unset($form['path']);
    unset($form['revision_information'])开发者_StackOverflow中文版;
    unset($form['author']);
  }
  } 

However - I can not find (even in debugger) what variable to unset to disable Input Format options to prevent users from changing default format. Do you other way to do that?


HOOK_FORM_ALTER will work if we make sure our hook is being called after filter_form_alter (or hook from any other module altering form). This is being done by setting our module weight in drupal system table to be bigger than others we compete with. It is usually done in hook_install:

db_query("UPDATE {system} SET weight = [yournumber] WHERE name = 'yourmodulename'");

Drupal uses weight field to determine order or calling hooks.

Taken from: http://drupal.org/node/110238

Hope it will help someone.


Hm, why dont you just set up your filter formats so that normal users dont have more than one, and simply remove the administer filters permission from everyone, that's not 'cruel' that's called 'secure'.


Disable "administer filters" permission works but it feels kind of cruel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜