Problem/Motivation
After posting a node-add form with only URL in a field which only 'Link text' is required the form does not allow the user to change his mind and not post anything for the link field.
How to reproduce:
- Create a link field
- Do not check the link field option
Required field - Select
RequiredforAllow link text - Open the for to add a new node and add text only for the link URL
- After submitting the form it will display an error message that the link filed is required
- Delete the text at the URL and submit the form again (Suppose the user do not want to fill this link anymore)
- The form will not change the
requiredattribute and will not allow the user to give up inserting something.
The expected outcome would be allow the user to change his mind and not post anything for this field, as it is done before submitting the node-add form for the first time.
Proposed resolution
- Add help text for the 'Link text', something like : The link text will be required if you insert an URL.
- Change the attribute required of 'Link text' in case the user deletes what he/she has input for URL.
Comments
Comment #2
chhavik commentedComment #3
chhavik commented- Added help text for the 'Link text' field.
- Fixed the required condition of the 'Link text' field, when the user deletes what he/she has input for URL.
Comment #4
chhavik commentedIgnore Comment #3 as the patch name is incorrect. Attached the correct one here.
Comment #5
mac_weber commented@chhavik thank you for the patch. Don't worry too much about the patch name. It is good to follow the patch name suggestion, but the patch works even if it is different.
Can we change the error message displayed in this case? It reads:
Link text field is required.while it is required only when we have input at URL. Then, maybe something like:Link text field is required if you enter an URLComment #6
mac_weber commentedjust fixing a small typo at the issue title
Comment #7
chhavik commentedUpdated the error message as
Link text field is required if you enter an URLComment #8
mac_weber commentedlooks good
Comment #9
mac_weber commentedComment #10
chhavik commentedFixed small typo. It should be 'a URL'. Please review it again.
Comment #12
chhavik commentedUpdated Unit Test as per the new error message.
Comment #13
mac_weber commented@chhavik the correct wording is "an URL" as in the patch you had posted at #7
Comment #15
chhavik commentedIdeally it should start with
anas it's a vowel. But i googled a lot,ais used with URL and notan.English can sometimes be funny :)
https://en.wikipedia.org/wiki/Uniform_Resource_Locator
Comment #16
mac_weber commented@chhavik ok I've found a good explanation for it: http://itknowledgeexchange.techtarget.com/writing-for-business/which-is-...
Thank you for catching that.
Comment #17
catchThe test changes don't cover the actual 'required' problem, only the text changes themselves.
Since this includes string changes, it could only go into 8.1.x - although it looks like we could skip those and just fix the required behaviour?
Comment #18
mac_weber commented@catch since the strings as they are presented today to the user would be misleading the user, I think they can be considered a bug to be fixed in 8.0.x
Regarding the tests, probably we better add the remaining tests at the parent issue in which we have been discussing all tests which we will do for the required Link fields. These tests are very related and I already had a chat with you on IRC, which came to the comment #57 I posted on the other issue: https://www.drupal.org/node/2613924#comment-10671482
I am changing to RTBC again, but feel free to change the status if you think different or if we need to discuss more on this issue.
Comment #19
alexpott@catch != alexpott (re comment #57 on the other issue) :)
Anyhow I agree with @catch that we should add a test that fails on HEAD but passes with this patch to this issue. The steps outlined in the issue summary look a good place to start...
Comment #23
john cook commentedI've done a reroll of remove_required_for_link_text-2634232-12.patch because of March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase.
Comment #24
john cook commentedSetting to "Needs review" to run the tests.
Comment #25
mac_weber commentedPostponing in favor of #2613924: Link text isn't marked as required
Let's use part of the tests that are being added in the other issue.
Comment #38
dcam commentedThe steps to reproduce the issue are no longer reproducible. I think the issue was solved by #2613924: Link text isn't marked as required, which is what this issue was postponed on. If you believe that this issue is still relevant, then feel free to reopen it, but you'll need to update the steps to reproduce it in the issue summary.