PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 19, 2022

[FIXED] How to pass a value to laravel controller which is not in a form input in VueJS

 April 19, 2022     laravel, php, vue.js     No comments   

Issue

In my VueJS application, I have a form to submit some data

Admin can fill the same data for aother system user as well.

When an admin fill these data for a different user, I need to store that user's user id in the DB.

I'm fetching that user id from the URL.

But I'm struggling to pass that user's user id with the rest of the form data.

How can I pass that user id with the rest of the data to my laravel

This is how I fetch the user id and store it

var url = window.location.href;
var url_split = url.split("/");
var my_id_location = url_split.length - 2;
var my_id = url_split[my_id_location];

This is how I pass my form data

            const formData = new FormData()
            formData.append('match_id', this.matchId)
            formData.append('ground', this.ground)
            formData.append('played_at', moment(this.dateOfStart).format('DD-MM-YYYY'))
            formData.append('ended_at', moment(this.endedDate).format('DD-MM-YYYY'))

Since my_id is not a form data, how can I pass that value ?


Solution

It's same what you did with form data. Add like this

formData.append('my_id', my_id)


Answered By - S N Sharma
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing