When creating a new node with the Link field, if your field setting is "Let the user decide" for the target attribute, the default value is set up incorrectly in the node edit form: it is checked by default, and I think either you should have the option to set it one way or the other, or it should be unchecked by default on a new node.
The culprit is in link_process() where it sets up the editing form. For a new node, $attributes is set to $field['attributes'], which gives the 'target' component a value of LINK_TARGET_USER or 'user'. Then link_process() uses this code to set up a checkbox:
if (!empty($field['attributes']['target']) && $field['attributes']['target'] == LINK_TARGET_USER) {
$element['attributes']['target'] = array(
'#type' => 'checkbox',
'#title' => t('Open URL in a New Window'),
'#return_value' => LINK_TARGET_NEW_WINDOW,
'#default_value' => $attributes['target'],
);
}
That doesn't work well in that last line where the default value is set, because Drupal evaluates it as TRUE and checks the box, even though you really don't want it to be checked.
This change makes it work:
'#default_value' => ($attributes['target'] == LINK_TARGET_NEW_WINDOW) ? TRUE : FALSE,
Sorry I haven't made a patch... I'm under a deadline trying madly to get a site working... but anyway it's just one line that needs a fix and I thought I'd report the issue.
http://drupalcode.org/project/link.git/blob/refs/heads/6.x-2.x:/link.mod...
Comments
Comment #1
damienmckennaThank you all for your efforts, but I'm sorry to say that the D6 version is no longer supported.