I'm building a Vue app. When I click the button in the form I want to fill the input with value paypal and then submit the form. But from test_form.php (it's the file action of the form) the variable $_POST['paymentMethod'] contains null instead of paypal! Where I'm wrong?
Here is the code I'm using:
HTML:
<form action="test/test_form.php" method="POST" ref="form">
  <button type="button" v-on:click="setMethod('cc')">Credit card</button>
  <button type="button" v-on:click="setMethod('paypal')">Paypal</button>
  <input type="text" name="paymentMethod" required v-model="selectedMethod">
</form>
Javascript:
new Vue({
  el: "#app",
  data: {
    selectedMethod: null,
  },
  methods: {
    // Set payment
    setMethod: function(type) {
      this.selectedMethod = type; // Here I fill the field
      this.$refs.form.submit(); // Then I submit the form
    },
  }
});
 
     
    