Quick example (I did not test it, watch out on typos)
class MyCustomValidatorHandler extends eZContentObjectEditHandler
{
const base = 'ContentObjectAttribute';
function fetchInput([...] $contentObjectAttributes [...] )
{
$http = eZHTTPTool::instance();
foreach( $contentObjectAttributes as $contentObjectAttribute )
{
$inputName = self::base . '_' . $contentObjectAttribute->attribute('data_type_string') . '_' . $contentObjectAttributes->attribute( 'id' );
// Here you can filter also on identifier by getting value form $contentObjectAttribute
if ( $http->hasPostVariable( $inputName ) )
{
$formInput = $http->postVariable( $inputName );
}
}
}
The attribute ('data_type_string') return me type like"eztext" but, the data type of the field name (in the submitted form) is "data_text"... and so on for other data types...
There's another attribute I've to specify instead of 'data_type_string'?
Could you explain in details what are you trying to do? Why do you need validation for existing datatypes? They already has some validation where this is needed. Do you need something extra?
I have feeling that content edit handler and validation is miss used a bit here. Hope I'm wrong ;)
You can do mapping between submitted contentobject attribute identifiers and their appropriate input form names. The identifier you can get from the $contentObjectAttribute
> There's another attribute I've to specify instead of 'data_type_string'? Actually, this is defined in the templates of the datatypes, and is unfortunately not following any rules so could be anything.
If you only need for that attribute use something like:
For all datatypes you can simply check their validateObjectAttributeHTTPInput() or fetchObjectAttributeHTTPInput() methods to see what kind of post parameter pattern they use. eztext: kernel/classes/datatypes/eztext/eztexttype.php
Every content contains some "free fields" and others fields (two images and a movie) that can be filled ONLY if the users have enough "credits".
I'll check credits client-side but I wanna be sure that the "main" control will be made after submission server-side (to avoid hacks and tricks ;) ) , so I wanted to check with validateInput: check submission of three extra fields, if they are submitted, check credits and then validate or not.
The problem is to retrieve specifics fields names to validate...
Sorry for my poor english (and my poor ez-knowledge... ;) )
Hi guys, first of all I wanna thank you for your guidelines, I solved almost all my problems...
I have another question... I have to validate an object (in a custom edit handler), but in validateinput function I'm not able to retrieve the parent node id until I don't publish it.
I check conditions in publish function, I can remove the node but I'm not able to alert the user after redirect.