Laravel Voyager Relationships Validation Error - laravel

Similar issue to: 4920 and 5108 in Github
After creating a relationship and setting them as "required" to have input:
Relationship with Rule/Validation
If there is nothing in the field after I submit, the validation message appears which is the expected behavior. Whenever I input anything into the field and submit, the form still releases the error message and won't let me submit the form which is unexpected.
Error
If I remove the JSON validation, it works and just submits as null/empty. I need the validation.
In 4920 and 5108 they said they solved it by placing the validation in a different field, but they didn't state where or which field to input the validation; can anyone point me in the right direction or tell me what the right field is?

Related

Pre-filling a hosted MailChimp signup form with an email address shows validation errors

We're trying to pre-fill the email address field of a hosted MailChimp form. Here's the blog post that talks about exactly this matter: https://blog.mailchimp.com/how-to-pre-fill-items-on-your-mailchimp-hosted-form/.
So here's our Newsletter signup form without any validation errors:
https://camping.us2.list-manage.com/subscribe/post?u=761a52bbd46ab21474b3af314&id=5cc638b5e6.
The problem arises when I add an email address to the URL as the value for the first form field, MERGE0, like this (url-encoding the email address, so # becomes %40):
https://camping.us2.list-manage.com/subscribe/post?u=761a52bbd46ab21474b3af314&id=5cc638b5e6&MERGE0=test%40camping.info.
Now, the form correctly copies the email address into the input field with name MERGE0 but it also displays three validation error messages:
Note: the email address field is mandatory.
When I try to pre-fill the user's first or last name fields adding MERGE1=John or MERGE2=Doe to the form's url, all is well - no error happens. It seems to be a problem with mandatory fields.
I'm arguing that this is a problem on MailChimp's side but they refuse to help saying that this is custom code and none of their business.
Can anybody help fix these errors?
It turned out that the problem was caused by a mistake in the URL.
Instead of camping.us2.list-manage.com/subscribe/POST?u=761a52bbd46ab...
it had to be camping.us2.list-manage.com/subscribe?u=761a52bbd46ab...
And the errors were gone!
This really made sense in the end, because posting the form should actually trigger the validation.

Laravel 5.5 form validation with VueJs2

I am just wondering if you had a similar problem as me. Hope you can help me out.
I ve got a form inside vue component:
<form>
(vuecomponent :errors="{{$errors}}")</form>
Its returning array with forms errors:
errors:Array[2]
0:"The price field is required."
1:"The product field is required."
My quiestion is how to decide which error msg goes to which input field inside vue component.
The array may vary depends on how many errors we ve got back. I cant use this:
this.errors[0] go to 1st input etc
Any ideas ?

Form is not submitting

My form (Html.BeginForm) was submitting well, i added some records over the period of one month using this form.
Then i did some cleanup (i don't remember those cleanups :( ) and tested the form after some time and now it is not submitting with a date value.
I mean, there are some date fields associated with master and child models, if child's date fields are filled (no matter parent's date is filled or not), the form does not get submitted and if these are empty then it does provided this is the first attempt i.e. if i attempt first with filled dates and then with empty dates, submitting does not work. I have two validation summaries with excludePropertyErrors true and false, no error is shown.
I had custom date format, dd-MMM-yyyy, and respective unobtrusive validator as jQuery.validator.methods["date"]. The behavior is same after removing these on both IE and Chrome.
However, a sample form submitting to the same controller's action on the same view with a sample model depicting the same structure works fine !!!
How to troubleshooting this??
Seems to me that the model binder is working correctly for your expected params, but that specific form is not passing in the values correctly (while your test form does).
These are the things your should try:
Use the browser's built in network logger and see what your POST looks like
Check the cAsE and spellnig of your variable names on the form (they should match your params/POCO on the action signature)
Hope this helps some.
Thanks BiffBaffBoff for compare the two. I figured out the problem by enhancing the sample model, controller and view, adding fields and validations one by one and finally got the issue. It was my authorization action attribute which was missing on one of the Remote validation action for date, my controller requires authorization.
Thank you all who tried to help me out, without even looking at single line of code.

Validate field and throw exception in JSF, but attach error message to another field?

I have some fields on my page which I want cross-validated. But I don't want error from this validation to be displayed in <h:message> for this fields.
If I add validator to any of the fields, and validator throws exception, error is displayed in <h:message> for this field. On the other hand I HAVE TO throw exception if I want to suppress page from submitting. Just displaying some error message is not enough.
So I created some hidden field on the form, and attached validator there. This validator has access to UIComponents of the fields I want to validate, so it can validate them. When validator throws exception, error shows in <h:message> for hidden field, which I can place anywhere I want.
Everything works, if I put hidden field after the fields I want to validate. (If I put it before, hidden field validation is triggered before even UIComponents of my fields are updated).
The problem is it's nasty hack :) Is there some better way to do it?
The problem is it's nasty hack :) Is there some better way to do it?
Not for the particular functional requirement. It's very true that JSF allows very little fine grained control for cross-validation of multiple fields.
Everything works, if I put hidden field after the fields I want to validate. (If I put it before, hidden field validation is triggered before even UIComponents of my fields are updated).
Components are during validations phase processed in the order as they appear in the component tree. If you have at some point an UIInput at hands which is still to be processed yet, then you need to grab the submitted value by UIInput#getSubmittedValue(). If it is already been processed, then you need to grab the submitted (and converted and validated) value by UIInput#getValue() instead.
So, if you put the hidden field with the validator after the to-be-validated components, then you need UIInput#getValue() to grab the values. If the hidden field is put before the to-be-validated components, then you need UIInput#getSubmittedValue() to grab the values.
i have got this code working for me:
throw new ValidatorException(new ArrayList());
no errors were displayed.

How does one show multiple validation errors near matching multiple field locations instead of the default one at a time?

Let's say you have an apex:form with ten apex:inputFields. All these fields are required and there are validation rules for all these fields that don't permit empty fields.
Given the error condition state of 10 empty fields, the default behavior of visualforce is that after you click on the submit button, it shows only one of the 10 errors at a time near the field location. This is done via the standard controller as it seems to throw an exception for the last error (as opposed to aggregating all the errors and then throwing the exception)
My question is then, how do you show multiple visualforce validation inputfield errors near their respective field locations instead of the standard one at a time? (which is annoying because you have to both fix the error and then click the submit button ten separate times!)
Yeah it's irritating, you'll need to use jQuery to get a neat solution. There's an article detailing the process here: http://developinthecloud.wordpress.com/2010/03/02/visualforce-form-validation-enhanced/.

Resources