Posted By

berkes on 04/05/07


Tagged

drupal FAPI formalter node-type


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

basicmagic
kellyharding


Per node type flag.


 / Published in: PHP
 

A form alter implementation to create variables to flag certain features per node type. E.g. Show foo on blogs only: example_blog == 1;

  1. /**
  2.  * Implementation of form_alter
  3.  */
  4. function example_form_alter($form_id, &$form) {
  5. if (isset($form['type'])) {
  6. if ($form['type']['#value'] .'_node_settings' == $form_id) {
  7. $type = $form['type']['#value'];
  8. $form['example'] = array(
  9. '#title' => t(''),
  10. '#type' => 'fieldset',
  11. );
  12. $form['example']['example_'. $type] = array(
  13. '#title' => t('Type has XXX'),
  14. '#type' => 'checkbox',
  15. '#default_value' => variable_get('example_'. $type, 0),
  16. '#description' => t(''),
  17. );
  18. }
  19. }
  20. }

Report this snippet  

You need to login to post a comment.