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
After requesting a translation and reviewing the translation the next step is usually to save the review, but if we try to save the review and the title field is empty we get an error since every node must have a title.
Proposed resolution
Add an error message if you try to save a review that contains an empty title field.
Remaining tasks
create patch, Review and commit.
User interface changes
Data model changes
Original report by [juanse254]
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff-256683-7-14.txt | 2.19 KB | juanse254 |
#14 | Review_job_item_empty-256683-14.patch | 3.07 KB | juanse254 |
| |||
#7 | interdiff-256683-6-7.txt | 1.12 KB | juanse254 |
#7 | Review_job_item_empty-256683-7-TEST-ONLY.patch | 1.19 KB | juanse254 |
| |||
#7 | Review_job_item_empty-256683-7.patch | 2.14 KB | juanse254 |
|
Comments
Comment #2
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedThis should fix it, tests needed.
Comment #5
joshi.rohit100t() => $this->t()
Comment #6
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedThis will pass the tests i guess, still working in the tests.
Comment #7
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedTests Added, this should be it.
Comment #10
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedComment #11
joshi.rohit100can we use short array syntax ?
Comment #12
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedWe could but following the way the rest of the test is written, leaving it the way it is would be the best.
Comment #13
miro_dietikerThe domain of a job, item and data item is completely decoupled from the node source.
We can not just check for a magic key like "title" and claim it can not be empty because it results in fatal errors.
What we know is that the source contained text and thus a valid translation can not be empty.
Independent of the item name, we should always warn about such a situation and possibly deny it.
(I'm pretty sure there are very special cases where this is not a valid check but let's ignore them until we found them...)
If this is not enough, a source would need to be able to declare that an item is required / can not be empty so TMGMT can check the integrity constraints without doing item key assumption.
And finally, the source need to check the situation when writing things back and reject it. Anyway, as long as TMGMT doesn't know enough about the source constraints, any source might reject what is provided by tmgmt with its validation. Most importantly we should trigger entity validation on the sources.
Some aspects i mentioned above can be followups...
Comment #14
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedThis should do it, we need a diferent approach.
Comment #15
joshi.rohit100Do we use private in D8, I mean I have seen some places in core where we are using private but should we use this here ?
Comment #16
miro_dietikerThat traversing looks odd, although i see that validateTags does it similarly...
What confuses me is that we should know what data items are part of the screen and we should know through what we iterate. And if not, we should offer an API to avoid this ugly lookup with trial-and-error...
We might need to discuss with Berdir, but i really think TMGMT should provide better helpers here.
Comment #17
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedPrivate it's fine if we just want that function to be called inside the class.
About @miro_dietiker comment, then maybe we better create a follow up to discuss this and if it's the case add those helpers.
For me this issue seems solved and the code looks good.
Comment #18
BerdirCan someone open a follow-to discuss how to improve this?
Messing with the form is ugly, I don't think we can change that. But what we can consider to change is move this to the API, possibly even give the source a chance at validating.
Not all fields are required, it should be fine to leave a non-required field empty for example. The content entity source could then account for that.
Comment #19
miro_dietikerHm, you didn't push. I thus committed and pushed now...
Followups still not created.
Comment #21
miro_dietikerCreated followup for extended validation:
#2587823: Validate review form through source plugins