+ Reply to Thread
Results 1 to 3 of 3

Thread: set error code for addError

  1. #1
    SunWuKung is offline Junior Member
    Join Date
    Nov 2008
    Posts
    8

    Default set error code for addError

    Hi,
    I am adding custom error messages to elements, but I am only able to add message as a string, while validators seem to add it as an array with the error code as the key. This way I end up with different error format depending on where the error came from.

    When I need to return the errors in xml to external applications this is a big problem for me. Any idea how to do this correctly?

    Thanks for the help.
    SWK

    Here is what I mean:

    Code:
    When I do: $element->addError ( $message );
    $form->getMessages() returns:
    array(1) {
     ["some_field"] => array(1) {
       [0] => string(16) "custom_message"
      }
    }
    
    When a validator fails on the element
    $form->getMessages() returns:
    array(1) {
      ["some_field"] => array(1) {
        ["some_errorcode"] => string(16) "custom message"   
      }
    }

  2. #2
    thomas is offline Senior Member
    Join Date
    Aug 2008
    Posts
    173

    Default

    Use the second parameter of addError(); for the key.
    Greetings
    Thomas Weidner
    I18N Team Leader, Zend Framework
    http://www.thomasweidner.com

  3. #3
    SunWuKung is offline Junior Member
    Join Date
    Nov 2008
    Posts
    8

    Default

    Looking at the documentation and the code I couldn't find the place where addError will take the second parameter.

    Doing $element->addError ( $message, $key ) seems to make no difference - the second parameter is ignored.

    Is this what you have suggested or should I do something differently?

    Thanks for the help.
    SWK

+ Reply to Thread

Similar Threads

  1. How to control the Code???
    By Developer in forum Forum Feedback
    Replies: 3
    Last Post: 03-07-2009, 05:10 AM
  2. error view shows php code
    By scope in forum Installation & Configuration
    Replies: 2
    Last Post: 03-06-2009, 06:27 PM
  3. same code for whole module
    By eXcuvator in forum Model-View-Controller (MVC)
    Replies: 3
    Last Post: 10-06-2008, 04:32 AM
  4. Zend_Form .. where does the code go?
    By BJM in forum Core Infrastructure
    Replies: 2
    Last Post: 04-18-2008, 09:05 AM
  5. HTTT 500 error code when Fatal Error happens
    By Georgy in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 10-23-2007, 12:32 PM

Posting Permissions

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