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

stevefrost78's avatar

Vue component from PHP form

I have a form that is created using a form builder (http://kristijanhusak.github.io/laravel-form-builder/)

It has three select elements: department, roles, managers

I want to wrap these three elements in a vue component and then update the values in javascript.

Roles and managers are unique to a department, when Laravel initially renders the form, it has the roles and managers relevant to the selected department, if the department is changed, I need to load the new departments roles and managers and then update the options of the two selects. Any ideas?

0 likes
1 reply
click's avatar

The combination of a form builder that outputs html and changing the values with vuejs based on other form fields is not going to work well. It is possible with just plain javascript or jQuery. But VueJS won't do anything for you here if you use the html form builder.

You can create your own component that creates this form for you. You can pass the required data for the selects as propsand than render your form with vuejs. Than you can easily populate the select fields based on another input field.

This requires some vuejs experience. There must be some examples out there that should give you a good start but I can't find one at this moment.

update see for a simple example https://codepen.io/anon/pen/aJOOOe?editors=1010 found in SO ticket: https://stackoverflow.com/questions/42470501/vue-js-dependent-select

Please or to participate in this conversation.