So what I basically have/need is a small bit of code that takes a
given form and converts the error messages to some JSON for a
javascript layer to process to do various effects.


    $result          = array();
    $result['Saved'] = False;

    $formOptions = $form->getWidgetSchema()->getOptions();
    $nameFormat = $formOptions['name_format'];

    foreach( $form->getErrorSchema() as $k => $v ) {
        $id      = get_id_from_name( sprintf( "{$nameFormat}", $k ));
        $options = $form[$k]->getWidget()->getOptions();
        $result[$id] = array( 'id' => $id,
                              'error' => $v->__toString(),
                              'label' => $options['label'] );
    }

    print json_encode( $result );

Is what I have.  This however falls apart with embedded forms though,
as I then just get "sf_guard_user_profile" instead of the
"sf_guard_user_profile_fullname" that I need when making 'profile' an
embedded sfGuardUserProfile form to sfGuardUser..

So my question really is: is there a reliable way to simply get errors
in a form with the HTML element ID for each?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to