[ckan-dev] new extra-field

Sean Hammond sean.hammond at okfn.org
Thu Oct 4 09:03:17 UTC 2012


Hi, the way to add a custom field to datasets is to implement the
IDatasetForm and use its db_to_form_schema() and form_to_db_schema()
methods (or for groups, IGroupForm has the same two methods).

Then if you want your custom field to be saved in the dataset (or
group)'s extras you would use convert_to_extras() and
convert_from_extras() in your db_to_form_schema() and
form_to_db_schema().

One thing to watch out for: convert_to/from_extras() is not compatible
with the 'free extras' that normally appear at the bottom of the dataset
form, so you need to override the form template and remove the free
extras from it (as well as adding your own custom fields).

There's are working examples of this for CKAN 1.8 called
ckanext-example_idatasetform and ckanext-example_igroupform on this
branch:

https://github.com/okfn/ckan/compare/master...2750-add-docs-and-examples-for-idatasetform-and-igroupform

> On Wed, Oct 3, 2012 at 4:57 PM, John Martin <john.martin.okfn at gmail.com>wrote:
> 
> > Hullo,
> >
> > 11am works for me as well.
> >
> > Also: I've been working on adding follower support back into CKAN 2.0 in
> > order to get the theme ready for the new personalization features. Sean:
> > Just a heads up I've got a couple of minor tweaks that I need to talk to
> > you about in relation to getting the changes into master. Let's talk about
> > them after the call tomorrow.
> >
> > .jm
> >
> > On Wednesday, 3 October 2012 at 14:47, Sean Hammond wrote:
> >
> > Back from Lux/Cambridge and wanted to catch up on where we are with
> >
> > 1. PD_EU Personalization features *(Sean/John)*
> > 2.Integrating LODStats/Virtuoso/SPARQL to enhance and enable better
> > suggestions and results *(Sven).*
> >
> > PLMK if you have a bit of time tomorrow - 11AM BST
> >
> >
> > I can do 11 tomorrow. Rufus has had us all working on urgent stuff to do
> > with the demo sites etc. so I basically haven't looked at pdeu at all
> > yet, except doing a bit of thought about how to implement the email
> > notifications.
> >
> > For the work that John and I will be doing I created a milestone on the
> > ckanext-pdeu github issues so we can collect, assign, prioritise,
> > discuss etc. the tickets, you and Ira could look through this and see if
> > you think anything's missing or would like anything changed:
> >
> > https://github.com/okfn/ckanext-pdeu/issues
> >
> >
> >
> 
> 
> -- 
> Andreea Bonea
> Project Manager
> Open Knowledge Foundation
> http://okfn.org/
> Skype: luthieneye


On Thu, Oct 04, 2012 at 09:54:17AM +0200, Crossbreed wrote:
> <html><body><div>HI!</div> <div> </div> <div>I would like to add
> an extra-field which is presented in an combobox. The functionality
> should be similar like them from groups - it should be possible to add
> more than one value (like groups). Therefore I need an extra-field,
> called education, with the format extras:education[value1, value2,...
> valueN]. I still have an extension where I add some extra fields.
> Therefore it´s not the problem HOW to add extra fields, but
> rather to define the correct schema of it. However, what´s the
> best way to add (and read) this field to the schema (in the methods
> db_to_form_schema and form_to_db_schema)? - It need to be saved within
> the "extras".<br /><br />kind
> regards!</div><br/><br/><hr/>Schau dir gleich die Seite von hsdf an!
> <a href="http://my.sms.at/crossbreed/"
> target="profil_sms_at">http://my.sms.at/crossbreed/</a><br/><hr/>Dein
> Eventkalender auf sms.at! Events anlegen, Freunde einladen & kein
> Top-Event mehr verpassen! <a href="http://www.sms.at/events/">ht
> tp://www.sms.at/events/</a><br/></body></html>

> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev





More information about the ckan-dev mailing list