Abhoryo / APYJsFormValidationBundle

This bundle performs validations of a form in javascript. (i18n compatible and several javascript frameworks supported)
92 stars 23 forks source link

custom constrain, geocomplete plugin from jquery #53

Closed bastienEichenberger closed 9 years ago

bastienEichenberger commented 10 years ago

Hi all,

First of all, I would like to say thanks you for your great work. Your bundle works fine…

I write an application who use geocomplete plugin from jquery and I have some troubles to translate my javascript to a custom javascript constraint.

I would like to translate this:


// on the geocode:error event valid display error
$('#fos_user_registration_form_adresse').bind("geocode:error", function(event, result) {
    //display the error
});

 $('#fos_user_registration_form_adresse').bind("geocode:result", function(event, result) {
    //clear the error -> this is ok
 });

I have no idea how to do this in my twig.js function:


function IsAdresseValid(field, params)
{
    var value = field && field.nodeName ? {{ getJsFormElementValue('field') }} : field;

    if (isNotDefined(value)) {
        return true;
    }
    return getComputeMessage(params.message);
}

Thanks your for your help. Have a nice day.

Abhoryo commented 10 years ago

This is an error generate by a javascript plugin so I think this has nothing to do with this bundle. But you can use directly the translator bundle to translate your error messages.

See this bundle documentation

Translator.get('key'); with the default domain