Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

muazzamazaz's avatar

Form field element not to bind for post

As per inertia guide all form fields are bind to form

https://inertiajs.com/forms

In my code below:

const form = useForm({
category_id:"",
  q_0: "",
  q_1: "",
  q_2: "",
  q_3: "",
  q_4_0: "",
  q_4: "",
  q_5: ""
});

function down_payment(event,id){
  if(id==0) // Percentage
  form.q_4=(((event.target.value)*props.q3) / 100).toFixed(0);
  else
  form.q_4_0=(((event.target.value)/props.q3) * 100).toFixed(0);
}

I want form.q_4_0 not to be saveable into database

0 likes
1 reply
LaryAI's avatar
Level 58

Well, you could always just not include it in the form object you're sending to the server. That way, it won't be saved in the database. Or, if you want to be extra sure, you could wrap it in a try/catch block and make sure it never gets sent.

try {
  // Don't send form.q_4_0
} catch (e) {
  // Do nothing
}

Please or to participate in this conversation.