Share » Forums » Developer » Dynamic form creation, validation and...

Dynamic form creation, validation and storing of data

Dynamic form creation, validation and storing of data

Friday 07 January 2011 1:59:13 am - 5 replies

Author Message

Edi Modrić

Friday 07 January 2011 3:56:26 pm

Hi Matthew,

you could create a custom datatype that suits your needs (supports collection) and in the process, write custom validation code.

That way, validation process would nicely plug in to eZ Publish publishing and collecting process.

The following article can get you started on creating your datatype:

http://share.ez.no/learn/ez-publish/creating-datatypes-in-ez-publish-4

eZ Publish certified developer

http://ez.no/certification/verify/350658

Bertrand Dunogier

Tuesday 11 January 2011 1:24:25 am

Hi, and welcome !

The closest thing I can think of is the ezsurvey extension: http://projects.ez.no/ezsurvey. It is quite old (there might be newer versions out there), but it shows an approach to dynamic form. It doesn't use jQuery or anything really fancy, but it might give you ideas.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Matthew Dawkins

Tuesday 11 January 2011 2:30:36 am

@Edi Thanks for that link re custom datatypes. Looks like quite an involved process for something so simple, and even then I'm not sure it actually fits the bill because I need an arbitrary number of inputs rather than EZP knowing beforehand what's coming.

@Bertrand Yes I had a look at ezsurvey before, but not as a source of inspiration for making my own extension, which looks like my best option at the moment. I'll have a look at the source code for that and see if I can glean any info about dynamic forms which I can use.

At the moment my general feeling is that despite EZP's obvious power and flexibility, it's far from being a rapid development platform - it's so complex that even doing something simple seems to take forever. I'm trying my best not to be put off, but it seems like an uphill climb at the moment!

Patrick Kaiser

Tuesday 11 January 2011 3:43:57 am

A custom datatype can store anything what you want. You can either use a dedicated table for it or store the value as a serialized php array. And yes, you maybe right, that there is no really simple way of doing this "the ez way", especially if you are not yet familiar with ez internals. Have a look at the build in matrix datatype, since it already does most what you need.


Best regards,

Patrick

Gaetano Giunta

Tuesday 11 January 2011 5:21:57 am

You can create a custom datatype that allows a variable number of values to be stored into it. It will be quite a bit of work, but I think it would be very, very much welcome by the community if done properly.

You could look at the code that does the 'variable number of items' part for those datatypes that allow that at the class level (eg. the options datatypes) and morph it into something that does the same but at the object level.

But that could prove also to be insufficient if what you want to do is to have a list with a variable number of values where each value is in fact not a scalar value but a complex object in itself (eg. pet's name, type, age, etc). In that case you might want to create one content object per pet, as child of the current node (or one information-collection per pet). Usage of the powercontent extension and some serious ajax/javascript-fu most likely needed.

Principal Consultant International Business
Member of the Community Project Board

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu