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

thusfar's avatar

Vue - How to add a new field to form?

So I want to add new field to Update Contact Information form.

I open file /vendor/laravel/spark/resources/assets/js/settings/profile/update-contant-information.js and I make this changes:

data() {
        return {
            form: $.extend(true, new SparkForm({
                name: '',
                email: '',
                isBusiness: 0 // new line
            }), Spark.forms.updateContactInformation)
        };
    },
ready() {
        this.form.name = this.user.name;
        this.form.email = this.user.email;
        this.form.isBusiness = this.user.isBusiness;  // new line
    },

And then I run Gulp. However these new lines are not visible in app.js after gulp is compiled.

Why? And how to make this work?

0 likes
4 replies
thusfar's avatar

I finally got it working. It appears it was cache issue. Before I posted here I emptied cache and did a hard reload, but it wasnt working. Now after some time it works. Btw. I'm using Cloudflare. Maybe this will help someone someday.

EventFellows's avatar

You are changing in the wrong place. You should make your custom changes in \resources\assets\js\spark-components\settings\profile\update-contact-information.js

You are breaking your chance of updating spark later if you change in the place you mentioned (eventhough it should also work)

thusfar's avatar

Could you tell me how would I make these changes in

\resources\assets\js\spark-components\settings\profile\update-contact-information.js

Do I just override ready() and data() methods?

EventFellows's avatar
Level 16

It's quite simple. Every file in vendor folder has its equivalent in \resources\assets\js\spark-components. And everything you put into the \resources\assets\js overwrites the setup in vendor folder (or adds it if it does not exist in vendor folder)

So simple put your code into the resources file, that's it. That is also the way to overwrite spark methods in js code without physically overwritting them.

1 like

Please or to participate in this conversation.