Laravel 5.1 using a variable name in view files

Can someone explain why the following thing does not work in laravel 5.1: I am viewing the login1.blade.php file

@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 the links in master.blade.php:

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

This generates 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> 

thanks

+5
source share
1 answer

I believe the problem is with the definition of the section. You are using two different sections with the same name for the same query. If the form section is defined, it is cached and used later with the same code. This link may be the other way around.

+1
source

Source: https://habr.com/ru/post/1234942/


All Articles