Wednesday 27 January 2010 5:52:25 pm
Hi Alex I'll attempt to answer your questions - there is a lot to cover here :) - Is it possible to create/handle HTML form without using eZ content objects and their datatypes? Yes there are a number of solutions in the form of extensions. Check out eZ Survey (GPL, certified and part of eZ publish 4.2) or Form Builder from designIT (Commercial - I wrote this when I worked for them). Also check out Paul Wilson's article http://ez.no/de/developer/articles/how_to_create_ez_publish_forms
How to create custom/extra validation rules for the form? For example:
Need to:
* validate that input1 is greater than input2 (integer or date)
* validate that sum of input1 and input2 is not greater than specific number Strict requirement is that inputs don't loose their values after form was sent and was displayed again. You might be able to do something with eZContentObjectEditHandler Validation - See http://serwatka.net/blog/enhanced_content_edit_handler_for_validation_rules_in_ez_publish_4_1 The other option is to create a custom datatype to handle this situation. This is the option I'd choose.
- How to create different sets of validation conditions for different view-contexts of the form? Example: When adding object - validate all fields. When editing - just some of them. If adding/editing by admin - validate just one field. This is where you'd use eZContentObjectEditHandler Validation however I believe you cannot override the existing validation present in the base datatype. I think this is executed after.
- What are 'hooks' in terms of eZ Publish? Where can find an example of their usage? And how can they be used for adding custom actions for existing PHP modules?
For example in "kernel/user/register.php" you can find this line: $Module->addHook( 'post_publish', 'registerSearchObject', 1, false ); Hooks are mainly used to attach workflow but can be used in modules. There is not a lot of good documentation on this part of eZ. The following may be of some value
- http://pubsvn.ez.no/doxygen/trunk/html/classeZModule.html
- http://ez.no/doc/ez_publish/technical_manual/4_x/concepts_and_basics/workflows
- How to create view-context specific form input labels for the form? Example: Let's say for site administrator some form field labels are "Customer1 Name", "Customer2 Name" and for anonymous users those labels should be "Director", "Manager". The simplest way to do this is create an edit template override that is displays the required label dependant on the user/group viewing it. - How to create different forms for "Adding" and "Editing" content object and possibly with slightly different fields labels? As above but checking on the version number to determine if the object is new or not.
- How to post-process values of fields of sent form before adding/updating actual data to DB with custom PHP code? Example: Need to do 'normalization' of names before saving, like: user input was "john sMITH" and it should be "John Smith". Create a custom pre-publish workflow. Have a look at the items under http://pubsvn.ez.no/nextgen/trunk/kernel/classes/workflowtypes/event/ specifically http://pubsvn.ez.no/nextgen/trunk/kernel/classes/workflowtypes/event/ezwaituntildate/ezwaituntildatetype.php and http://pubsvn.ez.no/nextgen/trunk/kernel/classes/workflowtypes/event/ezapprove/ezapprovetype.php Hope this goes some way to answering your questions.
Cheers Bruce
My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish
|