There was an old issue dealing with such an problem: Certain combination of options will make the field validation fail.

The way to reproduce the bug is simple:

  1. create a new field
  2. set it as required
  3. set the URL as optional
  4. set the title as optional
  5. save

At this point the validation fails, telling that either a title or a URL should be entered. This error message is inappropriate on the field settings page, while a default value is not specified.

Comments

b-prod’s picture

Status: Active » Needs review
StatusFileSize
new2.25 KB

The patch below fixes the issue.

chris matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
Related issues: +#885364: Certain combination of options will make the field validation fail

The 5 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:
  if ($type == FALSE && $instance['settings']['validate_url'] === 0) {
    $type = LINK_EXTERNAL;
  }
  $url = link_cleanup_url($item['url']);
  $url_parts = _link_parse_url($url);

  // We can't check_plain('<front>') because it'll break.

error: patch failed: link.module:430
error: link.module: patch does not apply
philsward’s picture

Think I just ran into this...

I need to remove empty fields, but since the title is required, there is no way to remove them. (Thanks to Drupal not having a remove button for fields...)

The logic is wonky in that a required form within the field, despite all being blank, results in the page not saving to remove the empty fields.

Update: The field was not required, however Title was.

I believe there needs to be logic that "if all forms within link field are blank, ignore requirements and purge field".

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new805 bytes
damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll +Needs tests

Thank you, that condenses it down to the bare fix and applies correctly.

Let's add some test coverage to this too.