logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$10
Why does this fail?

I am getting:

Fatal error: Class 'validators' not found in
/home/dev/cache/aaa/dev/config/modules_mtr_validate_upload.yml.php
on line 14


This is a very simple comment form with just one input, a big textarea. My yaml file:

fields:
caption:
required: Yes
msg: Please provide a caption
myFile:
required: Yes
msg: Please provide a JPEG image file
validators: mtrImageValidator
file: true

mtrImageValidator:
class: sfFileValidator
param:
mime_types:
- 'image/jpeg'
- 'image/pjpeg'
mime_types_error: Only JPEG files are allowed
max_size: 102400
max_size_error: Max size is 10 megabytes

This question has been answered.

marshall | 07/23/10 at 11:10am Edit


(10) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    07/23/10
    2:25pm
    Arturo Linares says:

    Don't add the "validators" key, use just the name of the validator:


    fields:
    caption:
    required: Yes
    msg: Please provide a caption
    myFile:
    required: Yes
    msg: Please provide a JPEG image file
    mtrImageValidator:
    file: true

  • avatar
    Last edited:
    07/23/10
    2:25pm
    Loban Rahman says:

    Please resubmit your question with your yaml in a code block so we can ensure you got the tabbing right.

  • avatar
    Last edited:
    07/23/10
    1:04pm
    GlobalOrangeLab says:

    Hi, you can use this way!

    1)


    fields:
    caption:
    required: Yes
    msg: Please provide a caption
    myFile:
    required: Yes
    msg: Please provide a JPEG image file
    mtrImageValidator:
    file: true

    validators:
    mtrImageValidator:
    class: sfFileValidator
    param:
    mime_types:
    - 'image/jpeg'
    - 'image/pjpeg'
    mime_types_error: Only JPEG files are allowed
    max_size: 102400
    max_size_error: Max size is 10 megabytes


    OR

    2)

    fields:
    caption:
    required: Yes
    msg: Please provide a caption
    myFile:
    required: Yes
    msg: Please provide a JPEG image file
    mtrImageValidator:
    file: true


    mtrImageValidator:
    class: sfFileValidator
    param:
    mime_types:
    - 'image/jpeg'
    - 'image/pjpeg'
    mime_types_error: Only JPEG files are allowed
    max_size: 102400
    max_size_error: Max size is 10 megabytes



    Hope this will help you!

    Previous versions of this answer: 07/23/10 at 1:04pm

  • avatar
    Last edited:
    07/23/10
    11:41am
    marshall says:

    Loban, I just put the yaml in a block.

  • avatar
    Last edited:
    07/23/10
    12:06pm
    Loban Rahman says:

    I should have also asked this earlier? Which version of symfony is this? I'm assuming 1.0.

  • avatar
    Last edited:
    07/23/10
    12:14pm
    marshall says:

    Yes, version 1.0. But the first programmer who built this site customized it a lot. In settings.yml and factories.yml, some of the settings were off, like sessions auto_start was set to false, and flash was turned off. A lot of default settings were turned off. So when I see an error like this, I try to keep an open mind. This is the first time we are trying to use validators. For all I know he turned off some default setting about validators.

  • avatar
    Last edited:
    07/23/10
    12:40pm
    Loban Rahman says:

    According to Symfony 1.0 documentation at Chapter 10 - Forms, it should be as follows:


    validators:
    mtrImageValidator:
    class: sfFileValidator
    param:
    mime_types:
    - 'image/jpeg'
    - 'image/pjpeg'
    mime_types_error: Only JPEG files are allowed
    max_size: 102400
    max_size_error: Max size is 10 megabytes

    fields:
    caption:
    required:
    msg: Please provide a caption
    myFile:
    file: true
    required:
    msg: Please provide a JPEG image file
    mtrImageValidator:


    You need to define the "named validators" under "validators:".
    You need to put "file: true" directly under the field, it's not part of the FileValidator (Arturo made a mistake here).
    Then just refer to the named validator with no parameters.

  • avatar
    Last edited:
    07/23/10
    12:44pm
    Loban Rahman says:

    Oops, lets try that again. :-)

    According to Symfony 1.0 documentation at Chapter 10 - Forms, it should be as follows:


    validators:
    mtrImageValidator:
    class: sfFileValidator
    param:
    mime_types:
    - 'image/jpeg'
    - 'image/pjpeg'
    mime_types_error: Only JPEG files are allowed
    max_size: 102400
    max_size_error: Max size is 10 megabytes

    fields:
    caption:
    required:
    msg: Please provide a caption
    myFile:
    file: true
    required:
    msg: Please provide a JPEG image file
    mtrImageValidator:


    You need to define the "named validators" under "validators:".
    You need to put "file: true" directly under the field, it's not part of the FileValidator (Arturo made a mistake here).
    Then just refer to the named validator with no parameters.
    Also, there is no need for "Yes" after "required:".

  • avatar
    Last edited:
    07/23/10
    1:55pm
    marshall says:

    What comes after "mtrImageValidator:"

  • avatar
    Last edited:
    07/23/10
    2:20pm
    Loban Rahman says:

    Q: What comes after "mtrImageValidator:"?
    A: Nothing!

    mtrImageValidator is a "named" validator, in that you defined some default arguments for sfFileValidator, and named it mtrImageValidator. Hence, you just use mtrImageValidator with no parameters, because you have already defined them. Of course, a named validator is only useful if you use it in multiple places, otherwise you could have directly used the sfFileValidator like so:


    fields:
    caption:
    required:
    msg: Please provide a caption
    myFile:
    file: true
    required:
    msg: Please provide a JPEG image file
    sfFileValidator:
    mime_types:
    - 'image/jpeg'
    - 'image/pjpeg'
    mime_types_error: Only JPEG files are allowed
    max_size: 102400
    max_size_error: Max size is 10 megabytes

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.