API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21Fo...
Problem / Motivation
The documentation for \Drupal\Core\Form\FormBuilder::setErrorByName() looks like it needs to get an update. It currently makes a bunch of references to form_set_error() which is currently just a wrapper for ::setErrorByName and is also deprecated and slated to be removed.
At a minimum the documentation needs to be updated to remove reference to form_set_error() and replace it with FormBuilder::setErrorByName().
It also looks like this documentation was just copy/pasted from the old Drupal 7 form_set_error function so it's probably in-need of a thorough review to make sure it's still accurate and that the examples are still good.
Comment | File | Size | Author |
---|---|---|---|
#6 | interdiff-2-6.txt | 2.32 KB | cs_shadow |
#6 | drupal-2257283-6.patch | 3.51 KB | cs_shadow |
#4 | interdiff-2-4.txt | 2.17 KB | cs_shadow |
#4 | drupal-2257283-4.patch | 3.5 KB | cs_shadow |
#2 | drupal-2257283-2.patch | 3.48 KB | cs_shadow |
Comments
Comment #1
jhodgdonGood catch!
This is probably a good Novice project? My suggestion would be to replace references to form_set_error() in text to say "this method" or "of this method", as appropriate (some slight wording or word order changes may also be necessary). And then if specific calls are being made, replace it by FormBuilder::setErrorByName().
Other things I think would be good to fix:
- Where references are made to methods like "...and the submitdoCheckErrors handlers will run...", ?!? Make sure this refers to the correct method name, and it should be something like FormBuilder::methodName() [prefixed by FormBuilder:: and suffixed by ()]
- The two drupal.org links that are there with @see should be removed. They are linking to issues, which are generally not helpful for people to be linked to. Either just remove them, or find appropriate documentation pages to link to.
Comment #2
cs_shadow CreditAttribution: cs_shadow commentedDid following changes in the patch:
1. Replaced references to form_set_error() in text to say "this method" or "of this method", as appropriate. Replaced specific calls to form_set_error() by FormBuilder::setErrorByName().
2. Replaced references to form_set_error() by FormBuilder::getError() and form_set_errors() by FormBuilder::getErrors().
3. Replaced reference to submitdoCheckErrors by FormBuildersubmitdoCheckErrors()
Let me know if anything else is required here.
Comment #3
jhodgdonThanks, this looks really great!
One thing: (my bad!) -- I just noticed this change is on FormErrorInterface(), not FormBuilder(). So instead of linking to FormBuilder:: methods, we should link to FormErrorInterface:: methods. Like here:
and also the later references to getError() and getErrors().
One other thing: There is no such thing (as far as I can tell) as FormBuilder::submitdoCheckErrors() . I really don't have any idea what that was supposed to be? Let's see... Here's the current docs:
All I can think of is that "submitdoCheckErrors" was supposed to be just "submit" here. That would actually make sense to me. So the change in the patch to make this FormBuilder::submitdoCheckErrors() is not quite right. Again, my bad!
Comment #4
cs_shadow CreditAttribution: cs_shadow commentedDid changes as suggested in #3. Sorry to have overlooked the class names earlier. I don't understand what submitdoCheckErrors was supposed to mean, so for now I've changed it to just 'submit'. Let me know if this works.
Comment #5
cs_shadow CreditAttribution: cs_shadow commentedComment #6
cs_shadow CreditAttribution: cs_shadow commentedMissed an instance in the last patch.
Comment #7
filijonka CreditAttribution: filijonka commentedlooks ok for me
Comment #8
jhodgdonThanks! Looks good to me too.
Comment #9
jhodgdonThanks again! Committed to 8.x.