[ckan-dev] Customising the dataset form in 2.0

Sean Hammond sean.hammond at okfn.org
Wed Jan 23 19:59:49 UTC 2013


Hey, I just updated ckanext/example_idatasetform to work with CKAN 2.0:

https://github.com/okfn/ckan/pull/295

To add a new field to the dataset form I had to override four template
files.

templates/package/snippets/package_metadata_fields.html is where I add
the dropdown select box for my new field. To construct the dropdown I
need something that the plugin's setup_template_variables() adds to the
template context. But c is not available in
package_metadata_fields.html.

So I have to override the parent template that calls
package_metadata_fields.html and make it pass the extra data in. But c
is not available in the parent either, so I have to override the
template that calls that, and the template that calls that!

I think anyone trying to use a tag vocabulary, for example, would need
to do this.

Am I doing something wrong? Or should the templates be changed in CKAN so
that c is passed into the sub-templates?




More information about the ckan-dev mailing list