0

help me please, i want when i click the validate button i want to display form 2 and cache form 1, knowing that at the beginning i want to display form 1 and hide form 2, in my code when I click on the validate shows me the form 2 and also the form 1, but I want the form 1 to hide. form 1:

<div>
<h3>form group 1</h3>
@if ($message = Session::get('success'))
<div class="alert alert-success">
    <p>{{ $message }}</p>
</div>
@endif

 {!! csrf_field() !!}
<div class="form-group">
 <label>Date:</label>
  <input type="date" id="datePicker" name="date" class="form-control" placeholder="date naissance">
 </div>

Nbre de jour

valider form 2

 <div v-if="open">
   <table class="table table-bordered" id="mytable">
        <tr>
            <th>salaire net</th>
            <th>nbre de jour </th>
            <th>prime</th>
        </tr>
        @if($salaries->count())
            @foreach($salaries as $key => $salarie)
                <tr id="tr_{{$salarie->id}}">
                  <td>{{ $salarie->matricule }}</td>
                  <td >{{ $salarie->nom }} {{ $salarie->prenom }}</td>
                  <td><input type="hidden" name="salaire" value="{{ $salarie->salairenet }}">{{ $salarie->salairenet }}</td>
                </tr>
            @endforeach
        @endif
    </table>

    <div class="form-group col-md-offset-5 ">
    <button class="btn btn-success " type="submit" >Pointage mensuel</button>
    </div>
 </div>

code vuejs :

<script src="{{asset('js/Vue.js')}}"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

<script type="text/javascript">

    var app = new Vue({
        el: '#app',
        data: {
            open: false,

        },
      });
</script>
1
  • Don't use blade @if inside vue components. Declare all php variables as vue data, and use v-if instead. Commented Jun 16, 2019 at 2:31

1 Answer 1

1

Use v-if and v-else directives. You are already using v-if="open" in the form 2. Add v-else to the div container of the form 1. Keep in mind that always v-if has to be put before v-else.

You can read more about conditional rendering in the docs: https://v2.vuejs.org/v2/guide/conditional.html

Sign up to request clarification or add additional context in comments.

1 Comment

thx for u answer but i cant resolve my brlm ,i use else but without interest, i will search more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.