Updated core Form Block

Permalink
Hi

I'm trying to improve on the core Form block by adding client-side form validation.

I successfully created a new block to do this but ended with my own versions of btForm, btFormAnswers, btFormAnswerSets and btFormQuestions, the tables which hold all the forms and responses. But really all I wanted to do was add a 'validation' field to btFormQuestions, so this seemed a bit of overkill.

The other downside is I needed to create all the controllers etc for the Dashboard, so I could view all the responses. I started this but gave up.

So I tried creating a package which would override the original Form block. I uninstalled the core Form block via the Add Functionality page and installed my Forms block. I updated the Form block version to 2.0 in the package controller and added my field to db.xml. When I installed my block the field was successfully added to btFormQuestions.

However, now I get
"Cannot redeclare class FormBlockController"
When displaying any page which contains the new Form block.

I can get rid of this error if I destroy the concrete/blocks/form folder in the core.

I'm very close to having a new Form block with pretty good client-side validation, which I'm happy to release for free.

Any ideas of the correct way of doing this?

thanks in advance
Russell

russellfeeed
 
kino replied on at Permalink Reply
kino
russellfeeed replied on at Permalink Reply
russellfeeed
Thanks kino

Yes, you have the right idea but my validation uses jquery.validationEngine (http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/) which has a range of built in validations.

You can also set up relation ships between fields like checking if to password fields agree (although I haven't tried this in C5 yet)

Okay, it's not as easy as clicking a radio button like yours... you need to add a validation string like 'required,customer[ukpostcode]' but it works very nicely and can be expanded with you own regexes by editing the javascript.

Cheers
Russell
Remo replied on at Permalink Best Answer Reply
Remo
you can't use a class name which is already used. Rename the folder and your class, table name (db.xml) and it will work.

Please consider contributing to this project:http://sourceforge.net/projects/c5formblock/...
russellfeeed replied on at Permalink Reply 1 Attachment
russellfeeed
Thanks Remo

I'd seen your comments elsewhere about improving the form block but as there was no validation support it sort of got forgotton.

However, you have solved the problem of seeing the responses!

I can give you the code for the validation support.

It uses the jquery.validationEngine plugin.

See attached form.zip package. Should have everything you need and should be obvious what needs to change if you do a diff with the core Form block. There's no Dashboard support, but you have got that covered already.

Cheers
Russell