Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.1, using variable's name in view files

Can somebody explain why the next thing doesn't work in laravel 5.1: I've view file login1.blade.php

@extends('ajaxforms.form1')
@section('form')
<input type="text" name="email" /><input type="password" name="password" />
@endsection
@section('script')
<script type="text/javascript">var modalName = '#{{$modalname}}';</script>
@endsection
@section('link')
<li ng-controller="login_controller" id="login_controller">
<a href="#" data-toggle="modal" data-target="#{{$modalname}}">Sign in</a></li>
@endsection

register1.blade.php

@extends('ajaxforms.form1')
@section('form')
<input type="text" name="name" /><input type="text" name="email" />
<input type="password" name="password" /><input type="password2" name="password2" />
@endsection
@section('script')
<script type="text/javascript">var modalName = '#{{$modalname}}';</script>
@endsection
@section('link')
<li ng-controller="register_controller" id="register_controller">
<a href="#" data-toggle="modal" data-target="#{{$modalname}}">Sign in</a></li>
@endsection

..and form1.blade.php

<div id="{{ $modalname }}">
@yield('form')
</div>
@yield('script')
@yield('link')

And also links in a master.blade.php:

@include('ajaxforms.login1',['modalname' => 'modalLogin'])
@include('ajaxforms.register1', ['modalname' => 'modalRegister'])

This generates a code:

<div id="modalLogin">
<input type="text" name="email" /><input type="password" name="password" />
</div>
<script type="text/javascript">var modalName = '#modalLogin';</script>
<li ng-controller="login_controller" id="login_controller">
<a href="#" data-toggle="modal" data-target="#modalLogin">Sign in</a></li>

<div id="modalRegister">
<input type="text" name="email" /><input type="password" name="password" />
</div>
<!--Here I want to '#modalRegister' instead of '#modalLogin'; And register_controller 
instead of login_controller. Why doesn't work?????????????????????????-->
<script type="text/javascript">var modalName = '#modalLogin';</script>
<li ng-controller="login_controller" id="login_controller">
<a href="#" data-toggle="modal" data-target="#modalLogin">Sign in</a></li>

Thank you

like image 347
user2301515 Avatar asked Nov 09 '22 02:11

user2301515


1 Answers

I believe the problem is with the section definition, You are using two different section with same name for same request. If section form is once defined it is cached and used later with same code. This link can give the other way around.

like image 182
anwerj Avatar answered Nov 14 '22 22:11

anwerj