How to override the EZ automatic validation process ?

Author Message

Hakim Bouras

Wednesday 19 August 2009 1:27:52 am

Hi,

Ez Publish provides an automatic validation system when editing an abject based on the class description.

Would it be possible to "override" this automatic validation using a workflow extension ?

Something that will happen just after the automatic validation process is done, and that will provide us a way to change the output of the automatic validation (either by adding extra validation problem to the $validation template variable or by removing validation problems added by the automatic process).

If this is possible, what are:
- the event to plug in (before content publish ?)
- the variable storing the result of the validation
- how to change the result of the automatic validation (validation OK or problem) so that the normal EZ editing process can continue ?

Thanks for your help,
Hakim

Bruce Morrison

Wednesday 19 August 2009 2:26:52 am

Hi Hakim

My gut feeling is that the answer is that it's not possible. The validation is done in the datatype and I believe the content object will have to pass validation before it is published (so before the before publish workflow has a change to kick in).

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

Heath

Wednesday 19 August 2009 3:40:42 am

Hello Hakim,

I have provided similar features per unique customer requests in the past.

Most of the time depending on what your trying to do this gets complicated. Most will tell you it's not possible. That is not always the case. Often I have had great success with custom validation within copies of ezpublish datatypes to provide for more user friendly validation / storage / etc .

I find that for the most part, the best results are found in focusing your changes to the datateypes themselves (making variations with modifications)

- I have added ezimage datatype to ignore validation errors and always store the uploaded image regardless of other attribute validation errors. This helps editors greatly for example.

- I have manipulated other various datatypes to ignore default php code and content class definition attribute / datatype defaults (such as validation settings stored within the class definitions in the admin). This let a customer work with an existing configuration / content in a unique way which avoided default validation and instead provided extended clientside (javascript) and serverside validation which functioned in a more user friendly way.

This code was published as a number of projects, http://projects.ez.no/bcicfv

I hope this helps.

Cheers
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Hakim Bouras

Wednesday 19 August 2009 8:43:26 am

Thanks for you answers.

Since I am using version 4.1 of eZ Publish, do you know if the "Enhanced" content edit handler for validation rules in eZ Publish 4.1 might be a solution ?

Did you get to use it ?

It is not clear to me how it is possible, while using custom validation rules in some context (specific attributes, specific templates) to be able to call the "automatic" EZ validation process otherwise (as a default validation mechanism). Any idea ?

in my custom edit handler :

function validateInput( $http, &$module, ... ) {

    if (conditions for custom validation 1) {
        $result = manage_custom_validation1();
    } elseif (conditions for custom validation 2) {
        $result = manage_custom_validation2();
    } else {
        $result = HOW_TO_RELY_ON_EZ_AUTOMATIC_VALIDATION();
    }

    return $result;

    }	

Hakim

Bruce Morrison

Wednesday 19 August 2009 5:05:06 pm

Hi Hakim

I've had a quick poke around the source and documentation and it would appear that a Custom edit handler validateInput method provides <b>additional</b> validation that is performed after the validation present in the datatype. You can see this in kernel/content/attribute_edit.php 246-270 So it would appear that this method would be unsuitable for what you want to achieve.

Perhaps if you can provide some more context as to why you want to do this I may be able to provide an alternative solution.

Details on the Custom edit handler and the enhancement:
http://serwatka.net/blog/ez_publish_3_8_new_custom_edit_handler
http://pubsvn.ez.no/nextgen/trunk/doc/features/4.1/enhanced_custom_edit_handler.txt

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

Hakim Bouras

Thursday 20 August 2009 2:07:54 am

Hi Bruce,

Your explanations makes the picture a lot clearer, and I can now understand better the limit of what I wanted to achieve.

In fact, I am trying to move to version 4.1, and was having validation issues with custom edit templates which do not provide all the required fields existing in a class.

This was working fine, untill the version 4.1.

It looks like the easiest solutions will then be either for me to remove the "required" characteristic of the field, or to add the required fields back in the custom templates.

<b>By any chance, do you know where in the code the events "before publish" and "after publish" are triggered ?</b>

Thanks for your help,
Hakim

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.