Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Link module uses the same field validation when setting defaults for a field, as when submitting field values on a node. For this reason, when Title and URL are required, it's not possible to set a default Title but not a default URL.
Proposed resolution
Extend existing conditional to also test for $entity
, which will be set in the context of editing a node but not on the field configuration form.
Remaining tasks
- With the current patch, in the case that a default title is set without an accompanying default URL, an error will be generated if the title is left at the default and no URL is entered. If the field is not required, this leads to the unexpected result that a user cannot create a new piece of content without either providing a URL or deleting the default title. Proposed resolution: in validation, in the case that (a) the URL is empty and (b) the title is at the default, unset the title rather than raising an error.
- Maintainer requested an accompanying test.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff-1321094-15-21.txt | 1.34 KB | codi |
#21 | link-default_title-1321094-21.patch | 832 bytes | codi |
#11 | link-default_title-1321094-11.patch | 1.79 KB | jantoine |
#9 | link-default_title-1321094.patch | 694 bytes | AaronBauman |
#5 | link_6x_2x-allow_default_title_without_default_link-1321094-5.patch | 780 bytes | dqd |
Comments
Comment #1
AaronBaumanComment #2
dqd@aaronbauman, thanks for the patch! can at least two three users please confirm that it works and that should be committed so that I can commit ?
thx!
Comment #3
jcfiala CreditAttribution: jcfiala commentedI'm not able to get the patch to reply. I get this error:
Comment #4
AaronBaumanI must have rolled against an older version.
This patch works against 6.x-dev
Comment #5
dqdrerolled patch against latest dev for clean issue queue only.
... and as far as I can see it works.
Comment #6
dqdcommitted and pushed to HEAD.
authored by aaronbauman.
THX
Comment #8
AaronBaumanthis didn't make it into 7.x
Comment #9
AaronBaumanComment #10
jantoine CreditAttribution: jantoine commentedNew comments should be combined with existing comments before the code block (coding standards). Also, if the default Title is all that is populated when saving a node, the field should be ignored and not through an error. I'll tackle this in the distant future if no one else gets to it.
Comment #11
jantoine CreditAttribution: jantoine commentedUpdated the patch in #9 to apply to the latest dev release.
Comment #12
jantoine CreditAttribution: jantoine commentedThe patch in #11 wouldn't apply for me after I created it, perhaps due to the extra whitespace issues my editor automatically fixed. Attached is a patch in which I have removed all changes except for the fix found in #9 and which I was able to apply cleanly.
Comment #13
jcfiala CreditAttribution: jcfiala commentedUpdating to point to the current version.
Comment #14
erykmynn CreditAttribution: erykmynn commentedSorry if I'm a bit confused on this thread. I think this is the issue we're having with 7.x
Am I correct in surmising this fix made it into 6.x but is not committed to 7.x yet? or is at least not in the stable version?
Thanks!
Comment #15
Jaesin CreditAttribution: Jaesin commentedSame patch that applies to commit#: 4331edd (7.x1.2).
Comment #16
jcfiala CreditAttribution: jcfiala commentedGiven that we have a patch in the latest update, I'm updating this to "Needs Review".
Comment #17
codi CreditAttribution: codi commented#15 works great for me.
Comment #18
dqdtry to re-upload patch authored by @Jaesin for retesting and set issue to latest version 7.x-1.2.
---
... RTBC needs more than one review and we have no system test yet. Set back to Needs review.
Comment #19
dqdhm, for some reason d.o. system auto test doesn't work (maybe because its a FR, not a bug?)
Comment #20
dqd@Jaesin #15 : Sorry, can you please rewrite your patch following the Drupal coding and commenting standarts? (yes I know, the link module code is not 100% like this, but I would like to watch after it more) the //comment should be in the row before and not behind the code and Drupal prefers code wrapped in 80 bits per line maximum.
Thanks for understanding.
Patch works fine so far. Feel free to test by yourself following this link to a test enviroment: http://simplytest.me/project/link/7.x-1.2?patch[]=https://drupal.org/fil...
More reviews much appreciated. Thanks to all.
Comment #21
codi CreditAttribution: codi commentedHere's a new patch with the comment moved up. 80 char limit isn't a hard rule. I think the condition is fine the way it is.
Comment #22
Greg BoggsThis patch works when saving a node form, but if you try to edit the node with VBO, the error persists.
Comment #23
andyrigby CreditAttribution: andyrigby at Ixis - UK Drupal Support, Maintenance, Hosting and Development commentedPatch works fine for me on the field config form. Then when creating content the link title is populated by default.
Comment #24
nedjoThis is the issue that @jantoine noted in #10:
With the current patch, in the case that a default title is set without an accompanying default URL, an error will be generated if the title is left at the default and no URL is entered. If the field is not required, this leads to the unexpected result that a user cannot create a new piece of content without either providing a URL or deleting the default title. Proposed resolution: in validation, in the case that (a) the URL is empty and (b) the title is at the default, unset the title rather than raising an error.
Comment #25
thommyboy CreditAttribution: thommyboy commentedDid this not make it into the module- I miss the same function in D8!
Comment #26
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commented