SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)

    Zend_Form custom errors

    I've been having trouble setting multiple custom errors to the same field. I've made a custom validator to do this for me as it was needed before, but for something like checking valid email it shouldn't be necessary.

    I know to change the error message of a required field I'd use 'messages' => array('IsEmpty' => 'errer message here'). And I could use setErrorMessage() but I've only had success of adding 1 error to encompass all errors thus far.

    So How might I add IsEmpty error and also a seperate error for ValidEmail

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Does my question need rephrasing or do I have a stumper? I figure it wold be done with an array inside of addErrorMessages(); but I'm not sure how.

  3. #3
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know that the Email validator is a special case because it also proxies to the Hostname validator. This really complicates the error message change process.
    Adrian Schneider - Web Developer

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Well take another example in its place then. Alnum and NotEmpty for example.

  5. #5
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wrote some examples on a related stack overflow question.

    Short answer: pass 'messages' => 'string' to each validator to override per validator.
    Adrian Schneider - Web Developer

  6. #6
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Yes I've tried this. When one error is tripped it shows all errors.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •