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

Dependent field validator #152

Open
wants to merge 17 commits into
base: ckan_2.8
Choose a base branch
from

Conversation

bianca
Copy link
Contributor

@bianca bianca commented Sep 11, 2020

This PR consists of 10 commits to make the following changes:

  • add a javascript module to conditionally hide/show fields
  • add a validator to only save the value of a field if another field has a particular value
  • add a validator to make a field required if another field has a particular value
  • apply the javascript module to exemption, exemption rationale, and opened_date
  • apply conditional_save to exemption and exemption rationale
  • apply required_if to exemption, exemption rationale, and opened_date

bianca and others added 11 commits April 27, 2020 13:54
CKAN module added to hide/show fields based on the values of other fields in the package form.
Add the hide/show fields to exemption and exemption rationale fields based on the value for access level.
Add conditional save form validator that will wipe values from a field unless a different field has a particular value. This is so that exemption and exemption rationale fields can only be populated if access level is restricted.
…nale.

Add conditional_save validator to exemption and exemption rationale so that they can only have values if access level is restricted.
Make javascript file available to internal and external catalogues.
Apply validators to external catalogue only.
Validators moved to dedicated file. Required_if validator added and conditional_save validator finished.
Apply conditional show behaviour to opened_date so it only shows for opened datasets.
Apply required_if validator to opened_date, because it is only needed for opened datasets.
@boykoc boykoc self-assigned this Sep 16, 2020
@boykoc boykoc added the enhancement New feature or request label Sep 16, 2020
When form_attrs is passed in the schema, the class form-control doesn't automatically get passed to the form input and needs to be deliberately passed as part of of form_attrs.
Hiding/showing fields introduces accessibility issues, among others. Switch to toggling readonly instead.
Required_if validator refactored to be neater.
Providing form_attrs in the schema overrides passing 'col-md-6' to the textarea tag, so it must be manually passed through adding to form_attrs.
Textarea doesn't have readonly styles and appears to be editable. Add readonly styles.
Using 'raise invalid' with fluent fields does not attach an error to the specific field. Using the error dict does attach an error to the specific field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants