1

I followed several recommendations and decided to go with using CSS to hide the text format. I don't want to use another module to do something minor like this. Just want to hide text format for this particular form.

When I look at source I see:

<fieldset class ="filter-wrapper form-wrapper" id="edit-conditions-format">
blah blah blah 
</fieldset>

Then on top of my form render function I do:

drupal_add_css('
        #edit-conditions-format {
            display: none;
        } ',
      array('group' => CSS_THEME, 'type' => 'inline'));

I have cleared cache and the text format is still available. Any tips?

2

Your code is correct. Just add it to a custom module, and it will work. Most likely it doesn't work because the admin theme is not the same as your front end theme.

Your module would take as little as this:

YOUR_MODULE.info:

name = Your module.
description = Description.
package = Custom
core = 7.x
version = 7.x-1.0

YOUR_MODULE.module:

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'ID_OF_THE_FORM_YOU_WANT_TO_ALTER') {
    drupal_add_css('
      #edit-conditions-format {
          display: none;
      } ',
    array('group' => CSS_THEME, 'type' => 'inline'));
  }
}

That's it. You can fetch the empty boilerplate here or if you want to do it properly, have a main custom module where you do all the extra customizations. You can have a look at mine here.

Or you could create a child theme of the admin theme, but that will likely take as much effort as creating a custom module.

1

i guess you don't use the same theme for everything, and you're using a custom theme. so - this code won't affect the 'backend'.

you need to alter the admin theme, or the theme you use to edit content.

so hack your admin theme, or better sub-theme it, and add your css there. then set this to your new admin theme here: admin/appearance

  • 1
    The sub-theme part of your answer is good, but it's generally not good to suggest to hack the theme/module. – Aram Boyajyan Mar 3 '16 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.