laravel - Including Sub-Views in Blade -


i'm trying include 2 sub-views ( 'login' , 'register' ) in 'home' view this:

@extends('master')  @section('content')      @include('auth.login')         <hr>     @include('auth.register')  @endsection 

and 'login' , 'register' views:

//register.blade.php  @extends('master')  @section('content')  {!! form::open() !!}      <div class="form-group">         {!! form::label('email', 'email address') !!}         {!! form::email('email', null,              ['class' => 'form-control',               'placeholder' => 'email address',               'required' => true]) !!}     </div>      <div class="form-group">         {!! form::label('password', 'password') !!}         {!! form::password('password',              ['class' => 'form-control',              'placeholder' => 'password',               'required' => true]) !!}     </div>      <div class="checkbox">         <label>             {!! form::checkbox('remember', null, []) !!}             remeber me         </label>     </div>      {!! form::submit('login', ['class' => 'btn btn btn-primary']) !!}  {!! form::close() !!}  @endsection 

//login.blade.php @extends('master')  @section('content')  {!! form::open() !!}      <div class="form-group">         {!! form::label('email', 'email address') !!}         {!! form::email('email', null,              ['class' => 'form-control',               'placeholder' => 'email address',               'required' => true]) !!}     </div>      <div class="form-group">         {!! form::label('password', 'password') !!}         {!! form::password('password',              ['class' => 'form-control',               'placeholder' => 'password',               'required' => true]) !!}     </div>      <div class="checkbox">         <label>             {!! form::checkbox('remember', null, []) !!}             remeber me         </label>     </div>      {!! form::submit('login', ['class' => 'btn btn btn-primary']) !!}  {!! form::close() !!}  @endsection 

i've tried removing master extension sub-views didn't work. 1 sub-view being rendered. can't figure out, why that's happening?

main.blade.php

@extends('master') @section('content')      @include('auth.login')         <hr>     @include('auth.register')  @endsection 

for sub views have remove @extends('master'). have 2 options can think of.

you can add @parent directive.

register.blade.php

@section('content') {!! form::open() !!}  ...      {!! form::submit('login', ['class' => 'btn btn btn-primary']) !!}  {!! form::close() !!} @parent @endsection 

login.blade.php

@section('content')  {!! form::open() !!}  ...  {!! form::close() !!} @parent @endsection 

or remove sections.

register.blade.php

{!! form::open() !!}  ...      {!! form::submit('login', ['class' => 'btn btn btn-primary']) !!}  {!! form::close() !!} 

login.blade.php

{!! form::open() !!}  ...  {!! form::close() !!} 

see similar question.


updated per comments

if need access pages separately extract form code partials , include them needed.

main.blade.php

@extends('master') @section('content')      @include('auth.partials.login')         <hr>     @include('auth.partials.register')  @endsection 

setup stand alone pages.

auth/register.blade.php

@section('content')      @include('auth.partials.register')  @endsection 

auth/login.blade.php

@section('content')      @include('auth.partials.login')  @endsection 

setup partials

auth/partials/register.blade.php

{!! form::open() !!}  ...  {!! form::submit('login', ['class' => 'btn btn btn-primary']) !!}  {!! form::close() !!} 

auth/partials/login.blade.php

{!! form::open() !!}  ...  {!! form::close() !!} 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -