Hi
I ve upgraded from D6 to D7 and I have more content types than " Forum" that can be tagged with the Forum taxonomy so that they can be viewed inside the forums.
Nodes of these content type are not always marked as forum topics, so the taxonomy should not be required and the default -none- choice should be possible.
Since I moved to D7 the field is always required even if not set so in the field settings.
Seems like the module is overriding the choice.
Simone

Comments

cimo75’s picture

Hi
in forum.module line 626 I changed it to default to FALSE as a temporary solution

$form['taxonomy_forums'][$langcode]['#required'] = FALSE;

larowlan’s picture

Status: Active » Closed (works as designed)

Hi
For a more permanent solution, you can implement hook_form_alter in a custom module to set this.

/**
 * Implements hook_form_FORM_ID_alter() for forum_node_form().
 */
function MYMODULE_form_forum_node_form_alter(&$form, $form_state) {
  $node = $form_state['node'];
  $langcode = entity_language('node', $node); 
  $form['taxonomy_forums'][$langcode]['#required'] = FALSE;
}

Marking as works as designed as this is a specific use case, the generic use case is for forum-node-types to require the taxonomy.
Lee

cimo75’s picture

Hi larowlan
thank you for the code.
I still think the issue I pointed to is an area that just be revised, firstly, as i pointed out I can see many occasions where a content type may have just some nodes marked as forum topics, secondly because there is an inconsistency in the fact that even if I mark the taxonomy as not required for a given content type, this behavior is not reflected on the node add form, this is still an issue GUI wise and can be confusing.
Simone

derekwebb1’s picture

Status: Closed (works as designed) » Needs work

I added this:

$form['taxonomy_forums']['und']['#required'] = FALSE;

to a module as described above and that doesn't actually work.

Also, changing the weights of the module that I added that to does not help either.

The UI is likewise unable to override the line 625 in forum.module that sets this requirement to TRUE.

At this time the only way I have found to correct this is to hack the module as in #1.

EDIT: I also added this in both hook_form_alter and hook_form_FORM_ID_alter and though the code inside these functions is executed as expected, the requirement stays the same until you comment out line 625 where the reuirement is set to TRUE...

One More EDIT: We only have the forum content type on this system so I doubt it has to do with the content types that you use the field on.

cimo75’s picture

Version: 7.15 » 7.18

Latest version and the bug (or inconsistency) is still present.
S.

cimo75’s picture

rebump

darrylseto’s picture

Issue summary: View changes

Sorry to nag but the only way I could fix this for one of my sites was to change the core forum.module.

darrylseto’s picture

Still nagging. No longer sorry to do so. This bug has been around for two years now and it forces me to change a core module every time Drupal core changes.

Note that it is a bug as field settings are automatically over-written.

darrylseto’s picture

Priority: Normal » Major
darrylseto’s picture

Version: 7.18 » 7.30
darrylseto’s picture

I was able to make the module work by changing weights as per https://www.drupal.org/node/110238 where the '[the_other_module_name]' is 'forum'.
To keep this field required for Forums I used hook_form_alter() to set $form['taxonomy_forums'][$langcode]['#required'] to FALSE if $form_id != 'forum_node_form'.

Still does not solve GUI issue!

Version: 7.3 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

poker10’s picture

The form_alter approach works, but you need to play a bit with the module weights or use the hook_module_implements_alter(), see: https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_module_implements_alter/7.x

However if you set the field as not required, then you can get this warning: #1621334: Notice: Undefined property: stdClass::$forum_tid in forum_node_view() .

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.