[ckan-dev] Custom dataset form while keeping free extras

Sean Hammond sean.hammond at okfn.org
Wed Sep 4 11:09:49 UTC 2013


> I need to add some extra fields to the dataset form, while keeping the
> "free extras" functionality.
> 
> I spotted this comment in the package_metadata_fields.html template in
> the example plugin shipped with ckan master:
> 
> ```
> {# 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. #}
> ```
> 
> I suppose that this means the custom field gets duplicated in the form
> (both as the custom field and in the "extras"), with all the
> consequences. Am I right?

IIRC yes the custom field would be duplicated in the data that gets
posted when you submit the form, once in the top-level custom field and
once in the extras. The top-level copy would contain the new value, if
you were trying to update the field. But the extras copy would contain
the original value, and would end up overwriting the new one. So you
could not update the custom field.

> Is there any "proper" way to add extra fields (with custom editing
> widget / validation / ...) while keeping the free key/value fields
> functionality?

I don't think so, unless you fix CKAN to allow this to work. It *may* be
possible for an IDatasetForm to work around the problem somehow.




More information about the ckan-dev mailing list