Skip to content

Commit

Permalink
Merge pull request #24 from aneeshikmat/master
Browse files Browse the repository at this point in the history
Add Arabic Translation
  • Loading branch information
Sidney Lins authored Aug 24, 2018
2 parents 8f94ae8 + 5202f3a commit 753d68a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions AtLeastValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,31 @@ public function clientValidateAttribute($model, $attribute, $view)
'{attributes}' => implode(Yii::t('messages', ' or '), $attributesLabels),
]);

$form = strtolower($model->formName());
$form = $model->formName();

return <<<JS
function atLeastValidator() {
var atributes = $attributesJson;
var formName = '$form';
var chosen = 0;
$.each(atributes, function(key, attr){
var obj = $('#' + formName + '-' + attr);
var obj = $('#' + formName.toLowerCase() + '-' + attr);
if(obj.length == 0){
obj = $("[name=\""+formName + '[' + attr + ']'+"\"]");
}
var val = obj.val();
chosen += val ? 1 : 0;
});
if (!chosen || chosen < $this->min) {
messages.push('$message');
} else {
$.each(atributes, function(key, attr){
var attrId = formName + '-' + attr;
var attrId = formName.toLowerCase() + '-' + attr;
if($('#' + attrId).length == 0){
attrId = $("[name=\""+formName + '[' + attr + ']'+"\"]").attr('id');
}
\$form.yiiActiveForm('updateAttribute', attrId, '');
});
}
Expand All @@ -162,3 +170,4 @@ function atLeastValidator() {
JS;
}
}

7 changes: 7 additions & 0 deletions messages/ar/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'You must fill at least {min} of the attributes {attributes}.' => 'يجب عليك ملء {min} من الحفول التالية {attributes} على الأقل',
' or ' => ' أو ',
];

0 comments on commit 753d68a

Please sign in to comment.