Ok, your validator definitely looks good.
I can't say what's going wrong, but the following doesn't belong imo
and could
be causing problems. When you bind a form, it automatically runs ALL
the fields
through their validators, including fields from embedded forms:
foreach ($this->embeddedForms as $name => $form)
{
$this->embeddedForms[$name]->isBound = true;
$this->embeddedForms[$name]->values = $this->values[$name];
}
Also, try removing the updateIamgefileColumn method entirely and see
what happens.
The column should be run through the sfFormPropel::processUploadedFile
method,
which will throw an error if the value of your form's imagefile column
isn't
of type sfValidatedFile (which appears to be the problem currently).
That
may shed some light.
-Ryan
On Apr 9, 11:05 am, Arnold Ispan <[email protected]> wrote:
> Hello,
>
> Here is the validator code:
>
> <?php
> class sfFileImageValidator extends sfValidatorFile
> {
> protected function configure($options = array(), $messages = array())
> {
> /* size image options */
> $this->addOption('min_width');
> $this->addOption('max_width');
> $this->addOption('min_height');
> $this->addOption('max_height');
>
> /* we set a default value as image for mime type */
> $this->addOption('mime_types' , 'web_images');
>
> /* size image error messages */
> $this->addMessage('min_width', 'Image is not large enough (minimum is
> %min_width% pixels).');
> $this->addMessage('max_width', 'Image is too large (maximum is
> %max_width% pixels).');
> $this->addMessage('min_height', 'Image is not tall enough (minimum is
> %min_height% pixels).');
> $this->addMessage('max_height', 'Image is too tall (maximum is
> %max_height% pixels).');
> /* mime type error message */
> $this->addMessage('mime_types', 'Invalid mime type (%mime_type%). It is
> not an image file.');
>
> /* let's use the parent configure() to keep file validator configure()
> */
> parent::configure($options, $messages);
> }
>
> protected function doClean($value)
> {
> $validatedFile = parent::doClean($value);
>
> // we get the image size
> $size = getimagesize($validatedFile->getTempName());
>
> // check "image size x" vs "max_size_x"
> if ($this->hasOption('max_width') && $this->getOption('max_width') <
> (int) $size[0])
> {
> throw new sfValidatorError($this, 'max_width', array('max_width' =>
> $this->getOption('max_width'), 'width' => (int) $size[0]));
> }
>
> if ($this->hasOption('min_width') && $this->getOption('min_width') >
> (int) $size[0])
> {
> throw new sfValidatorError($this, 'min_width', array('min_width' =>
> $this->getOption('min_width'), 'width' => (int) $size[0]));
> }
>
> if ($this->hasOption('max_height') && $this->getOption('max_height') <
> (int) $size[1])
> {
> throw new sfValidatorError($this, 'max_height', array('max_height' =>
> $this->getOption('max_height'), 'height' => (int) $size[0]));
> }
>
> if ($this->hasOption('min_height') && $this->getOption('min_height') >
> (int) $size[1])
> {
> throw new sfValidatorError($this, 'min_height', array('min_height' =>
> $this->getOption('min_height'), 'height' => (int) $size[0]));
> }
>
> // return value
> return $validatedFile;
> }
>
> }
>
> Also tried with this validator:
> 'imagefile'=> new sfValidatorFile(array(
> 'mime_types' => 'web_images'
> ), array(
> 'invalid' => 'Invalid file.',
> 'required' => 'Select a file to upload.',
> 'mime_types' => 'The file must be of JPEG,
> PNG or GIF format.'
> )),
>
> No succes :(( the same error.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---