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

pharmonie's avatar

Pass data from vue to blade

I have a blade file with this setup:

<form>
   <div id="vue">
      <comp v-model="slot" />
   </div>
</form>

Inside the Comp.vue I have

<script setup>
const slot = defineModel()
</script>

How can I make the slot of the vue component be part of the blade's form, e.g. as an hidden input.

0 likes
4 replies
martinbean's avatar

@pharmonie You can’t. Blade templates are compiled to HTML before a single line of JavaScript is parsed and executed.

pharmonie's avatar

Thank you for you answer. Is there any (hacky) way to handle this else? E.g. from the vue comp, I could post the slot to the backend (with the user's IP address?) and if the blade form will be submitted, I submit the IP address as well and try to match them up?

martinbean's avatar

@pharmonie Describe the actual problem you’re trying to solve, not how you’re trying to solve it.

pharmonie's avatar

I am comping from a Laravel + Blade Stack and my old projects are using this. Nowadays I am using Inertia with vue and no blade. From a newer project I have a reactive meeting planning component that I want to re-use in an old project. The implementation was very straight forward and it's working.

All the component does, is selecting a time slot in a form, but in a fancy reactive vueish way. That's way I want to use it. Think of it as a datepicker.

The only downside I am facing now, is that I can't use the selected value in the parental blade form.

Please or to participate in this conversation.