-
Notifications
You must be signed in to change notification settings - Fork 8
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
WIP If the model contains errors, display inline errors in jsoneditor #60
base: master
Are you sure you want to change the base?
WIP If the model contains errors, display inline errors in jsoneditor #60
Conversation
…he JSON editor to 'always' in order to exhibit inline errors upon initialization.
@germanbisurgi Does this also prevent the form from being sent to the server in the first place? |
…eClientValidation' => true. It' s job is to collect and display inline validation errors within the json-editor form. It also remove the added ".has-error" classes that Yii-2 adds everywhere in the json-editor indiscriminately.
…undant error messages
|
||
public function clientValidateAttribute($model, $attribute, $view) | ||
{ | ||
return <<<JS |
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.
Does it work, when using multiple JSONEditor on the same Page?
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.
The ClientSideJsonValidator works with the first json-editor it finds. Currently, Widgets2 uses only one json-editor at a time.
The publication module relies on Widgets2 as a dependency, I manually tested it and found no errors. It's worth noting that the publication module doesn't actively use the ClientSideJsonValidator. Instead, relies on the the regular json-editor error messages during interaction.
If you have any potential scenarios that could conflict with this pull request, please let me know. I know this PR could create more issues than it solves :)
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.
I added an extra check for the editor. In any case, if for some reason an error occurs during this client validation step, The page will just submit the form normally (no AJAX) and proceed with the normal flow, meaning backend validation and showing an error summary
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.
Is ClientSideJsonValidator
specific to widgets2 or would it actually belong to https://github.com/dmstr/yii2-json-editor ?
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.
Is specific to widgets2
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.
No description provided.