formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 204 forks source link

How to use vuejs directives with former #608

Closed dhsont closed 3 years ago

dhsont commented 3 years ago

Hi, i want to use vuejs with former.

But i am not able to add vuejs directives in fields with former.

I want to achieve this

<select v-on:change="myMethod(this)" v-model="selecteduser" class="form-control" name="user_id"> 
    <option value="" selected="selected">Select  User</option>
    <option value="1">John</option>
    <option value="2">Tom</option>
</select>

I can achieve this using laravel collective form using following code

  {!!  Form::select('user_id', $users, null,  ['v-on:change'=>'myMethod(this)','v-model'=>'selecteduser','class'=>'form-control'])  !!}

I don't know how to achieve this with Former.

Is there anyone can help me with this.

dhsont commented 3 years ago

Ah i got solution.

there is method setAttribute(). we can use like

->setAttribute('v-on:change', 'myMethod(this)')->setAttribute('v-model', 'selecteduser')

Thanks for this very useful package. I am using this package from last 3-4 years, and i can't imaging laravel forms without this package.

stayallive commented 3 years ago

I was looking for this too tell you, glad too see you found it yourself too 👌