Specify relation column as required
Bhavya Bhut
Any update?
B
Benjamin Schneider
how is it possible that this is still open after 6 years?!
KP
hi, any updates for making relationship field required?
V
Vladyslav Shestakov
Really need this
Derrick Mehaffy
Merged in a post:
Prevent users from creating entries when the relationships are missing
r
rinzler
In Strapi 4.16.2, we can make a normal field required from the admin interface. This prevents us from creating entries, when those required fields are missing, which is very useful.
Now, this feature does not exist for relationships, but we often need to do this too.
Now, we can manually add the "required: true" to the API's relationship, but this actually has no effect, i.e. it only shows the red asterisk close to relationship field (in the content manager), but we can still create the entry without specifying a value for that relationship.
This is actually more a bug than a feature, but may also be feature, in case you never planned to make relationships required.
This is so important. I know many people need this feature. So, please, implement this asap. Thanks.
A
Ashxdev
hi, any updates here?
ІП-22мп Кемарський Микита
Any updates on it?
Marc Roig Campos
Jen Tak As you clearly explained, Strapi changed the object to work with relations.
Making required relations was working before but was not something Strapi supported.
We plan to work on this in the near future and is something we are discussing how to implement.
r
rinzler
Marc Roig Campos: After 1 year, such a fundamental feature for a CMS is not implemented. What else can be more important than this feature?
Jen Tak
Just wanted to add that the
required: true
option in schema.json
doesn't work since 4.5.0 where https://github.com/strapi/strapi/pull/14401/ was released.With that PR the content manager started submitting more complex object as the value for relations fields even if the value was empty. Unfortunately, this object passes through the
required
validator as it merely checks the value isn’t null or undefined.The validator will keep working in the REST API as long as the clients won't use this new object syntax. In other words, the validator works but can be circumvented by a specifically crafted request. So don't rely on it, if you positively must enforce the rule.
Jen Tak
In Strapi v4.3.9 if i add
required:true
to the field specification in schema.json
the relation seems to be enforced. The UX is a bit subpar: just flashing an error "<field> cannot be null" after trying to save. But better than nothing.Would be nice if the docs mentioned this. .)
Load More
→