Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultNullable() is not respected by fields plugin #218

Open
davidkron opened this issue Dec 6, 2016 · 3 comments
Open

defaultNullable() is not respected by fields plugin #218

davidkron opened this issue Dec 6, 2016 · 3 comments
Labels

Comments

@davidkron
Copy link
Contributor

I created a class implementing Validateable and have overridden the default nullable behavior with this code:

static boolean defaultNullable() {
    true
}

The fields plugin doesn't seem to respect this configuration, which results in all fields being required, instead of the opposite.

I am using Grails 3.1.x

@sbglasius sbglasius added the bug label Feb 24, 2017
@snimavat
Copy link
Contributor

snimavat commented Apr 1, 2017

I think this is because, fields plugins doesnt consider validateable but uses the constrait evaluator directly. instead, it can check if the bean is validateable, thn instead of explicitly evaluating constraints, just call validateable.getConstraintsMap

@sbglasius
Copy link
Member

In grails/plugin/formfields/BeanPropertyAccessorFactory.groovy:90 it uses the Grails build-in constraintsEvaluator and this evaluator apparently does not look at result from
static boolean defaultNullable() which would explain why the fields plugin does not obey the return value. This needs further investigation

@kevintanhongann
Copy link

I have just recently worked on the admin panel and it uses f:all to render the fields. The attributes that are marked as nullable:true is rendered to the display as required fields.

davidkron added a commit to davidkron/grails-fields that referenced this issue Aug 17, 2022
sbglasius added a commit that referenced this issue Feb 9, 2023
respect defaultNullable() of Validateable classes (issue #218)
sbglasius added a commit to sbglasius/grails-fields that referenced this issue Feb 10, 2023
* master:
  If field validation error codes are unresolved and fallback to the defaultMessage on the error, this defaultMessage must be escaped due to the possibility of user input being in the error message. Fixes issue gpc#323.
  Update readme.md
  respect defaultNullable() of Validateable classes (issue gpc#218)
  fix warning "Accessing config through dot notation is deprecated"
  Added Action: Stale issues and pr's
  Back to snapshot
  Release 3.0.0.RC1
  Use release versions of dependencies
  Update dependencies
  Bump up serverlet api version to 4.0.1
  Bump up Groovy to 2.5.5

# Conflicts:
#	build.gradle
#	gradle.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants