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

Formpages does not work when a required field is in the second page #386

Open
MandanaMoshref opened this issue Aug 14, 2023 · 1 comment

Comments

@MandanaMoshref
Copy link

ckan version: 2.10
ckanext-scheming: latest (installed on 01.07.2023)

have a field with required: true after the first form_page causes an error message while being in the first form_page.
It looks that the form_page only separates the field visually and ckan processes the whole field at once.

to reproduce the error:
scheming.yml -> Although the field "Resource" is a required field in the second form page, I cannot even see the second page, because in the first form_page I receive the error of not filling the Resource field as an obligatory field.

scheming_version: 2
dataset_type: test
about_url: http://example.com/the-camel-photos-schema

dataset_fields:

- start_form_page:
    title: Basic Info
    description: Required and core dataset fields

  field_name: title
  label: Title
  preset: title
  form_placeholder: eg. A descriptive title

- field_name: name
  label: URL
  preset: dataset_slug
  form_placeholder: eg. my-dataset

- field_name: owner_org
  label: Organization
  preset: dataset_organization

- start_form_page:
    title: Detailed Info
    description:
      These fields improve search and give users important links

  field_name: tag_string
  label: Tags
  preset: tag_string_autocomplete
  form_placeholder: eg. economy, mental health, government

- field_name: url
  label: Source
  required: true
  form_placeholder: http://example.com/dataset.json
  display_property: foaf:homepage
  display_snippet: link.html

resource_fields:

- field_name: url
  label: URL
  preset: resource_url_upload

- field_name: name
  label: Name
  form_placeholder: eg. January 2011 Gold Prices

- field_name: description
  label: Description
  form_snippet: markdown.html
  form_placeholder: Some useful notes about the data

- field_name: format
  label: Format
  preset: resource_format_autocomplete

Here a screenshot of the error:

@wardi
Copy link
Contributor

wardi commented Aug 14, 2023

@MandanaMoshref form pages don't change the way the underlying API/validation for datasets work. This means you can't have required fields on the second page because the initial package_create will fail when trying to complete the first page.

You could change the validation rules for required fields on the later pages to only enforce requirement when the package is not in draft mode, or when fields for the same page are submitted. This doesn't happen automatically with the form pages feature in scheming right now.

If you do come up with a general way to allow required fields in any scheming form page I would definitely consider including it in ckanext-scheming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants