Skip to content

Commit

Permalink
[#1894] Update docs and example_idatasetform to reflect changes
Browse files Browse the repository at this point in the history
I kept the example of removing the default key/value extras, as this is
what most people would want to do anyway, but mentioning that you have
the option of combining them both on CKAN >= 2.2.1
  • Loading branch information
amercader committed Aug 25, 2014
1 parent 500dc59 commit 3158a75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
@@ -1,9 +1,7 @@
{% ckan_extends %}

{# Remove 'free extras' from the package form. If you're using
convert_to/from_extras() as we are with our 'custom_text' field below then
you need to remove free extras from the form, or editing your custom field
won't work. #}
{# Remove 'free extras' from the package form, as we don't want to support
them on our example. #}
{% block custom_fields %}
{% endblock %}

Expand Down
14 changes: 12 additions & 2 deletions doc/extensions/adding-custom-fields.rst
Expand Up @@ -144,7 +144,8 @@ the templates. Create a directory called
``ckanext-extrafields/ckanext/extrafields/templates/package/snippets/``.

We need to override a few templates in order to get our custom field rendered.
Firstly we need to remove the default custom field handling. Create a template
A common option when using a custom schema is to remove the default custom
field handling that allows arbitrary key/value pairs. Create a template
file in our templates directory called
``package/snippets/package_metadata_fields.html`` containing

Expand All @@ -154,7 +155,16 @@ file in our templates directory called
:end-before: {% block package_metadata_fields %}

This overrides the custom_fields block with an empty block so the default CKAN
custom fields form does not render. Next add a template in our template
custom fields form does not render.


.. versionadded:: 2.2.1

Starting from CKAN 2.2.1 you can combine free extras with custom fields
handled with ``convert_to_extras`` and ``convert_from_extras``. On prior
versions you'll always need to remove the free extras handling.

Next add a template in our template
directory called ``package/snippets/package_basic_fields.html`` containing

.. literalinclude:: ../../ckanext/example_idatasetform/templates/package/snippets/package_basic_fields.html
Expand Down

0 comments on commit 3158a75

Please sign in to comment.