What I want to do is to pass current user's id to create a new link that belongs to that user. When I hit submit it keeps showing error message: user id field is required. I think there might be a mistake in my controller action, but can't figure it out.
screen
Try this:
Link::create(array_merge(request(['title', 'address', 'category_title']), ['user_id'=>$user]));
Related
I currently have an Angular 2 app where the user can submit a form to create a new item. When the submit button is clicked, it calls a function that sends the data to the server and navigates to a new page when the server confirms that the data has been saved successfully.
My problem comes because the form submission appends the form parameters to the URL. So for example if I had an input named title and submission took me to the route mytitle which is the input for the title field, Angular (or whatever injects the GET parameters) would try to navigate to mysite.com/mytitle?title=mytitle instead of just mysite.com/mytitle. Even adding [ngModelOptions]="{standalone: true}" to all of my inputs still leaves a question mark with no parameters after it.
This is a problem because it causes Angular to reload the app because the given route does not match any routes in my route definitions. Is there a way to disable the GET parameters being injected into the URL entirely? POST doesn't work either because I have nowhere to post to, and my next URL uses data from the form itself.
I found an answer to my question, the "Submit" button defaulted to being of type "submit", so changing it to type "button" removed the GET parameters injection behavior.
Check setValue in your form control. Example: Set value this way this.form.controls['val'].setValue='' rather than assigning an empty value
(i.e. this.form.controls['val'] == 0).
If your problem still exists, kindly add button type submit to the button and manually give the click function access to it.
I am new to wicket framework. currently i have a task to validate the form fields one by one (sequence). but By default Wicket shows error messages together in a one place in the form. I want the field to be validated sequential is there any components ? Or Please guide me in the right direction what i should do ?
For EX:
if i consider LoginPage which contains username,password with out entering anything if i submit the form . that should show first field username required even password not entered also. once i fill username next it should check password entered or not so like this sequential validation possible?
You can use a ComponentFeedbackMessageFilter to show feedback messages for each component separately.
Please read "Displaying feedback messages and filtering them":
https://ci.apache.org/projects/wicket/guide/6.x/guide/forms2.html#forms2_2
I am designing an application that needs to dynamically load a form via an AJAX request. There should be three "modes": "create user", "update user", and "view user" (readonly).
However in all three cases, I am fetching a resource - thus these should all be GET requests (I'm not talking about the URIs I use to actually submit the form). They're all (virtually) the same form, so I consider them to be the same resource.
It seems to me that I could do something like:
GET /forms/users // Get a blank form for creating a new user
GET /forms/users/u/1?mode="view" // Get a form that shows info for user 1
GET /forms/users/u/1?mode="update" // Get a form that allows updating info for user 1
Or something like:
GET /forms/users // Get a blank form for creating a new user
GET /forms/users?id=1&mode="view" // Get a form that shows info for user 1
GET /forms/users?id=1&mode="update" // Get a form that allows updating info for user 1
Would either of these be "correct" according to REST? Or should I do something else?
The URL should be describing the resource, something like:
GET /forms/info/user/new // form to create a new user
GET /forms/info/user/1 // form to view user 1 info
You can pass a query string parameter to make the form updatable. Ex:
GET /forms/info/user/1?updatable=true
But that sounds like a browser, not a REST concern. REST is for communicating with API, and updating the user info would just require a PUT verb instead of the GET.
So just add some javascript code to make the form editable by a user.
Use the GET for "view user" operation and to get the user properties, use the PUT for the "create user" operation and for "update user" operation use the PATCH. This is the way I used to do.
It's an unusual practice to get a form from the REST API, having the client side application to show entire forms fetching from the API.
In your case you're right I guess, the only alternative I can see is
GET /forms/user/add // Get a blank form for creating a new user
GET /forms/user/view/1 // Get a form that shows info for user 1
GET /forms/user/update/1 // Get a form that allows updating info for user 1
The unique code is given to whoever clicked like (only the first time he clicks)
in order to make sure that he is not going to have a unique code again. I have to have his fb id in my database, but I read that it is impossible to know the fb id of someone who clicks like. Is there a solution?
If the like button will be on my fun page, is it possible then?
I have already all the process of generating the unique code, and checking in my db if the code was used or know, I only have to keep in my db also the fb id to make sure he will not get more then once.
Create fangate (differentiate likers non-likers).
Is is_liker get user id with basic permissions.
On return after accepting the permission request check if user already got code.
If user never got code give him. Else display error message.
i have created a country select box as
$country= new Zend_Form_Element_Select('country');
in my user registration form ..
While selecting an country an ajax call is send and getting the state list
by creating another select box
$state= new Zend_Form_Element_Select('state');
in another action say stateAction()
Problem is that when i tried to validate registration form in the POST action
i cant retrieve the value from state
$form = new Users_Form_Register();
eg as $userObjectDetails->statename=$form->getValue('state');
as a solution i added tried to added a dummy variable $state in Users_Form_Register();
add addElement($state),unfortunately during value is loaded by ajax call the state list issue occure during validation of the form
please suggest a solution for the above
Thank you
You could try validating with javascript. jQuery has a nice validation plugin that lets you attach the validator to the form ID and define the rules you want to validate.