2👍
A lot to tackle here. First, you should set a “parent” Vue instance rather than creating a new Vue instance for individual input fields. For example, lets say you want to make the entire form a Vue instance, then when you open your form, set an id like this:
{!! Form::open(['id' => 'example']) !!}
Then, when you create your Vue instance, reference that id:
<script type="text/javascript">
new Vue({
el: '#example'
})
</script>
Next, this code you have is incorrect:
{!! Form::select('mailarchive', ['-' => 'No', 'Gold' => 'Gold', 'Silver' => 'Silver', 'Bronze' => 'Bronze'], null, ['class' => 'form-control v-model="mailarchive"']) !!}
Specifically, pay attention to this part: ['class' => 'form-control v-model="mailarchive"']
What you are doing here is creating some weird class. When you specify extra HTML attributes, you need to pass an array of those attributes like this:
{!! Form::select('mailarchive', ['-' => 'No', 'Gold' => 'Gold', 'Silver' => 'Silver', 'Bronze' => 'Bronze'], null, ['class' => 'form-control', 'v-model' => 'mailarchive']) !!}
From there, another problem is how you are using v-show
.
This is what you have: <div class="form-group v-show="mailarchive !='-'"">
Once again, for some reason, you are putting v-directives inside your class. Instead, use it as its own HTML attribute like this:
<div class="form-group" v-show="mailarchive !== '-'">
All that together, you should see something like this:
{!! Form::open(['id' => 'example']) !!}
<div class="form-group">
{!! Form::label('mailarchive', 'Mailarchive: ', ['class' => 'col-sm-3 control-label']) !!}
<div class="col-sm-6">
{!! Form::select('mailarchive', ['-' => 'No', 'Gold' => 'Gold', 'Silver' => 'Silver', 'Bronze' => 'Bronze'], null, ['class' => 'form-control', 'v-model' => 'mailarchive']) !!}
</div>
</div>
<div class="form-group" v-show="mailarchive !== '-'">
{!! Form::label('instance', 'Instance: ', ['class' => 'col-sm-3 control-label']) !!}
<div class="col-sm-6">
{!! Form::select('mailarchive', ['Select' => 'Select', '1' => 'SV01', '2' => 'SV02'], null, ['class' => 'form-control']) !!}
</div>
</div>
{!! Form::submit() !!}
{!! Form::close() !!}
</div>
<script>
new Vue({
el: '#example'
});
</script>
Here is a working example on jsfiddle: http://jsfiddle.net/zj8hwjc9/1/
0👍
You will need to bind the first field to a var with v-model=”mailArchive” then on the second form group use v-show=”mailArchive !=’-‘”