One Hungarian user reported on Drupal.hu that the weight is not added to the filter tips form component, if only one format is available. This could result in the filter tips appear in unexpected places. The attached patch moves the weight setting into the general part of the filter tip form component construction.

Comments

gábor hojtsy’s picture

Assigned: Unassigned » gábor hojtsy

This applies to both Drupal HEAD and 4.7.x, so if there is a 4.7.x prospect, the possibly this should be fixed there too.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

In fact, this needs some more work, since it is not the correct fix...

deelight’s picture

Version: x.y.z » 5.x-dev
Status: Needs work » Needs review

Adding:

$form['#weight'] = $weight;

just before "return $form" worked for me.

This gives :

function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) {
  $value = filter_resolve_format($value);
  $formats = filter_formats();

  $extra = theme('filter_tips_more_info');

  if (count($formats) > 1) {
    $form = array(
      '#type' => 'fieldset',
      '#title' => t('Input format'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
//      '#weight' => $weight,
      '#element_validate' => array('filter_form_validate'),
    );
    // Multiple formats available: display radio buttons with tips.
    foreach ($formats as $format) {
      $form[$format->format] = array(
        '#type' => 'radio',
        '#title' => $format->name,
        '#default_value' => $value,
        '#return_value' => $format->format,
        '#parents' => $parents,
        '#description' => theme('filter_tips', _filter_tips($format->format, FALSE)),
      );
    }
  }
  else {
    // Only one format available: use a hidden form item and only show tips.
    $format = array_shift($formats);
    $form[$format->format] = array('#type' => 'value', '#value' => $format->format, '#parents' => $parents);
    $tips = _filter_tips(variable_get('filter_default_format', 1), FALSE);
    $form['format']['guidelines'] = array(
      '#title' => t('Formatting guidelines'),
      '#value' => theme('filter_tips', $tips, FALSE, $extra),
    );
  }
  $form[] = array('#value' => $extra);
// next line fixes guideline placement (so it doesn't appear before the field)
  $form['#weight'] = $weight;
  return $form;
}
drumm’s picture

Status: Needs review » Needs work

Needs a patch file. See http://drupal.org/patch.

edhel’s picture

Hmm It's not fixed in 5.x & 6.x so far...

hanoii’s picture

Version: 5.x-dev » 5.7
Status: Needs work » Needs review
StatusFileSize
new428 bytes

I encountered the same problem and did the same as comment #3, with the difference that I just add the #weight information inside the esle clause.

Attached is the patch against drupal 5.7.

drumm’s picture

Version: 5.7 » 7.x-dev
Status: Needs review » Needs work

On code review, I think this bug exists in all versions of Drupal, so moving to the highest. To reproduce, test when only one input format is available.

drumm’s picture

Code needs work because I think the #weight element should be defined in one of the array initializations, probably $form['format']['guidelines'], not added afterward.

hanoii’s picture

Version: 7.x-dev » 5.7
Status: Needs work » Needs review
StatusFileSize
new576 bytes

I reviewed the patch I commited but adding weight to $form['format']['guidelines'] won't fix this problem. The initialization must occur on the root element of the form, which is defined properly when formats are more than one but not if it is just one.

I am attaching a modified patch of my first one (#6) with an initialization of a $form element with the weight element, but I believe it has to be a new line because there's no other initialization array to add this information to.

drumm’s picture

Version: 5.7 » 7.x-dev

Corrected for code style. Does apply to all maintained versions of Drupal, so needs review for 7.x first.

drumm’s picture

StatusFileSize
new783 bytes
cburschka’s picture

Applies. I don't notice anything different on the node/add/page form when only one input format is available. What conditions should this be tested with?

Status: Needs review » Needs work

The last submitted patch failed testing.

cburschka’s picture

Status: Needs work » Needs review
catch’s picture

Status: Needs review » Postponed (maintainer needs more info)

Marking to active needs more info until there's steps to reproduce. Seems like this might not be valid at all.

Balefire’s picture

StatusFileSize
new11.8 KB
new12.32 KB

Not sure if this is correct for me to post here, but as catch said in comment #15

... Seems like this might not be valid at all.

Ithought I'd show how I can reliably reproduce on my D5.14 installation & Opera 9.52, sometimes with Firefox 3 (but if it happens once on a content type, it will always be that way):

  1. Create new content type without body field.
  2. Add a couple CCK fields, but only one multi-line text box with filtering
  3. Go to add or edit content

I have attached a couple of images (without = without the patch, with = with the patch) to show the difference. Hope this helps.

sun’s picture

Title: Quickfix: always add weight to filter tips » Always add weight to filter tips
Version: 7.x-dev » 6.x-dev

Already fixed in 7.x: http://api.drupal.org/api/function/filter_form/7

However, that's not going to be backported to 6.x. Leaving decision to Gábor whether we still want to fix this in 6.x.

hanoii’s picture

Status: Postponed (maintainer needs more info) » Needs review

I wonder if we can bump this issue for both 6.x or 5.x? I keep on patching this as it's annoying when you have more than one filter tip on a form. Just changing status so it's not postponed and not sure if there's more info to provide, it should be probably a decision of whether to fix this or not.

thedavidmeister’s picture

Assigned: gábor hojtsy » Unassigned
Status: Needs review » Closed (won't fix)

looks like with 3 years of inactivity the decision to fix this is "no".

If we do want to pursue this, the patch in #11 no longer applies.

error: filter/filter.module: No such file or directory