Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation require message translate appear 2 #9

Open
Paul75 opened this issue Nov 26, 2016 · 5 comments
Open

Validation require message translate appear 2 #9

Paul75 opened this issue Nov 26, 2016 · 5 comments

Comments

@Paul75
Copy link

Paul75 commented Nov 26, 2016

Hello,

When I do :
Form::Textbox("Titre de l’événement, intitulé du spectacle :", "titre_evenement", array( "required" => 1, "validation" => new Validation_Required("L'élément <i>%element%</i> ne doit pas être vide ....") ) );

When I validate :
Error: Titre de l’événement, intitulé du spectacle is a required field. L'élément Titre de l’événement, intitulé du spectacle ne doit pas être vide ....

That means it take the error in english and in french....

Thanks

@avbdr
Copy link
Owner

avbdr commented Nov 26, 2016

what if you will remove required=1 from parameters?

@Paul75
Copy link
Author

Paul75 commented Nov 26, 2016

yes if i remove the require element it works....

@Paul75 Paul75 closed this as completed Nov 26, 2016
@Paul75
Copy link
Author

Paul75 commented Nov 26, 2016

Yes it works but if I remove and only give the validation option in lable not take the '*' red ....

@Paul75 Paul75 reopened this Nov 26, 2016
@Paul75
Copy link
Author

Paul75 commented Nov 27, 2016

Not resolve....

@JulienBohy
Copy link

JulienBohy commented Dec 6, 2016

Salut,

j'utilise également ce composant, et ce que nous avons fait c'est modifier la librairie et ajouter des gettext plus une traduction via un fichier .po
Exemple le fichier PFBC/Validation/MaxLenght.php

<?php
namespace PFBC\Validation;

class MaxLength extends \PFBC\Validation {
	protected $message;
	protected $limit;

	public function __construct($limit, $message = "") {
		$this->limit = $limit;
		if(empty($message))
			$message = gettext("%element% is limited to " . $limit . " characters.");
		parent::__construct($message);
	}

	public function isValid($value) {
		if($this->isNotApplicable($value) || strlen($value) <= $this->limit)
			return true;
		return false;	
	}
}
?>

Ensuite plus qu'a mettre en place le système de traduction via poedit ou autre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants