Fields are supposed to return errors in the $errors argument, not mess-up with form_set_error() themselves.

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new3.62 KB

Something like this.

dqd’s picture

Status: Needs review » Needs work

@Damien Tournoud: awesome! thanks for the patch. :)

... But before reviewing, can you please connect with duellj on this briefly? Sorry. I think he was after the same issue like you for other reasons, but his attempt looks slidely different. I would love to see the best of both in. ;) thx

Link to his issue and patch:
#1451288: Link widget should use hook_field_widget_error()

dqd’s picture

Status: Needs work » Needs review

ok after chatting with Damien on IRC he gave me the helpful hint, that actually both are needed. So I'll do it, as he recommended to me to do it: First I will commit this patch here and then I will probably add the other patch manually on top of this.

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll
Related issues: +#1451288: Link widget should use hook_field_widget_error()

The 7 year old patch to link.module does not apply to the latest link 7.x-1.x-dev and if still applicable needs a reroll.

Checking patch link.module...
error: while searching for:
  $optional_field_found = FALSE;
  if ($instance['settings']['validate_url'] !== 0 || is_null($instance['settings']['validate_url']) || !isset($instance['settings']['validate_url'])) {
    foreach ($items as $delta => $value) {
      _link_validate($items[$delta], $delta, $field, $entity, $instance, $langcode, $optional_field_found);
    }
  }

  if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' && $instance['required'] && !$optional_field_found) {
    form_set_error($field['field_name'] . '][' . $langcode . '][0][title', t('At least one title or URL must be entered.'));
  }
}


error: patch failed: link.module:263
error: link.module: patch does not apply