Zend_File_Transfer behaves exactly the same as Zend_Form.
Both components do not allow to overwrite existing options on a validator
instance.
The reason is that when you give a instance of Zend_Validate_Interface
(where you have to extend your validators from) you must already have set
any wished options as the setOptions() method is not defined within this
interface.
So the options array is only valid for all Zend validators but not for self
created validators.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Jacky Chen" <[email protected]>
To: "Thomas Weidner" <[email protected]>
Sent: Monday, March 30, 2009 7:28 PM
Subject: Re: [fw-general] Bug with zend_file addValidator method
sorry,it is Zend_File_Transfer_Adapter_Abstract, within the method
addValidator() of the class,the validator was instance before the
$options['messages'] been unset.
the code as following:
public function addValidator($validator, $breakChainOnFailure = false,
$options = null, $files = null)
{
if ($validator instanceof Zend_Validate_Interface) {
$name = get_class($validator);
} elseif (is_string($validator)) {
$name =
$this->getPluginLoader(self::VALIDATE)->load($validator);
$validator = new $name($options);
if (is_array($options) && isset($options['messages'])) {
if (is_array($options['messages'])) {
$validator->setMessages($options['messages']);
} elseif (is_string($options['messages'])) {
$validator->setMessage($options['messages']);
}
unset($options['messages']);
}
} else {
......
in the above highlight code,shoud change to :
$messages = false;
if (is_array($options) && isset($options['messages'])) {
$messages = $options['messages'];
unset($options['messages']);
}
$validator = new $name($options);
if ($messages) {
if (is_array($messages)) {
$validator->setMessages($messages);
} elseif (is_string($messages)) {
$validator->setMessage($messages);
}
}
Best Regards,
Jacky
2009/3/30 Thomas Weidner <[email protected]>
Sorry, but your description is not very descriptive.
Maybe you can give a example of what's your problem ?
PS: There is no Zend_File_Adapter class or component.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message ----- From: "Jacky Chen" <[email protected]>
To: <[email protected]>
Sent: Monday, March 30, 2009 12:05 PM
Subject: [fw-general] Bug with zend_file addValidator method
Hi there,
there is a bug for the method addValidator in Zend_File Adapter,it should
construct the validator instance after unset the options with messages.
Best Regards,
Jacky