diff --git a/ckanext/example_idatasetform/plugin.py b/ckanext/example_idatasetform/plugin.py index 2041810ab2c..b02e035bca0 100644 --- a/ckanext/example_idatasetform/plugin.py +++ b/ckanext/example_idatasetform/plugin.py @@ -75,6 +75,13 @@ def form_to_db_schema(self): converters.convert_to_tags('country_codes')] }) + # Add our custom_test metadata field to the schema, this one will use + # convert_to_extras instead of convert_to_tags. + schema.update({ + 'custom_text': [validators.ignore_missing, + converters.convert_to_extras] + }) + return schema def db_to_form_schema(self): @@ -91,6 +98,12 @@ def db_to_form_schema(self): validators.ignore_missing] }) + # Add our custom_text field to the dataset schema. + schema.update({ + 'custom_text': [ + converters.convert_from_extras, validators.ignore_missing] + }) + return schema def setup_template_variables(self, context, data_dict=None): @@ -140,5 +153,8 @@ def package_form(self): def check_data_dict(self, data_dict, schema=None): ExampleIDatasetFormPlugin.num_times_check_data_dict_called += 1 - return lib_plugins.DefaultDatasetForm.check_data_dict(self, data_dict, - schema) + # Disable DefaultDatasetForm's check_data_dict(), because it breaks + # with the new three-stage dataset creation when using + # convert_to_extras. + #return lib_plugins.DefaultDatasetForm.check_data_dict(self, data_dict, + # schema) diff --git a/ckanext/example_idatasetform/templates/package/snippets/package_metadata_fields.html b/ckanext/example_idatasetform/templates/package/snippets/package_metadata_fields.html index 7d90b2489d9..a5f82e2cc32 100644 --- a/ckanext/example_idatasetform/templates/package/snippets/package_metadata_fields.html +++ b/ckanext/example_idatasetform/templates/package/snippets/package_metadata_fields.html @@ -33,6 +33,8 @@ +{{ form.input('custom_text', label=_('Custom Text'), id='field-custom_text', placeholder=_('custom text'), value=data.custom_text, error=errors.custom_text, classes=['control-medium']) }} + {# {% block custom_fields %} {% snippet 'snippets/custom_form_fields.html', extras=data.extras, errors=errors, limit=3 %}