-
Notifications
You must be signed in to change notification settings - Fork 23
Using messages from ZF validators + fix buildInlineJavascript for arrays, functions + added (commented for now additional-methods JS) #50
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
base: master
Are you sure you want to change the base?
Changes from 7 commits
70b5864
06380a4
12a8ecd
bac7ccc
c9707bc
e7eb365
7aea08a
4cf7fb2
ca37c54
736acab
0623300
bfb4bd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ public function preRenderForm($formAlias, View $view, FormInterface $form = null | |
| if ($options->getIncludeAssets()) { | ||
| $assetBaseUri = $this->getHttpRouter()->assemble([], ['name' => 'strokerform-asset']); | ||
| $inlineScript->appendFile($assetBaseUri . '/jquery_validate/js/jquery.validate.js'); | ||
| //$inlineScript->appendFile($assetBaseUri . '/jquery_validate/js/additional-methods.min.js'); | ||
| $inlineScript->appendFile($assetBaseUri . '/jquery_validate/js/custom_rules.js'); | ||
| if ($options->isUseTwitterBootstrap() === true) { | ||
| $inlineScript->appendFile($assetBaseUri . '/jquery_validate/js/jquery.validate.bootstrap.js'); | ||
|
|
@@ -106,7 +107,16 @@ protected function buildInlineJavascript(FormInterface $form, Options $options) | |
| { | ||
| $validateOptions = []; | ||
| foreach ($options->getValidateOptions() as $key => $value) { | ||
| $value = (is_string($value)) ? $value : var_export($value, true); | ||
|
|
||
| if(is_string($value)){ | ||
| if(strpos($value, 'function') === 0){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a unit test for this case please? Than we can also see if we can improve this code a little because it is a littlebit messy now with all these if / else statements.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not very familiar with unit tests unfortunatelly. |
||
| //nothing to do | ||
| } else { | ||
| $value = '"' . $value .'"'; | ||
| } | ||
| } else { | ||
| $value = json_encode($value); | ||
| } | ||
| $validateOptions[] = '"' . $key . '": ' . $value; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,7 @@ public function getRules(ValidatorInterface $validator, ElementInterface $elemen | |
| public function getMessages(ValidatorInterface $validator) | ||
| { | ||
| return [ | ||
| 'range' => | ||
| sprintf($this->translateMessage('The input is not between %s and %s'), $this->getMin($validator), $this->getMax($validator)) | ||
| 'range' => sprintf($validator->getMessageTemplates()[\Zend\Validator\Between::NOT_BETWEEN], $this->getMin($validator), $this->getMax($validator)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This message need to be passed through the translator. You can use the same method as before |
||
| ]; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include the asset and don't remove this line