Home > Blockchain >  how do i add a section inside a section in Laravel
how do i add a section inside a section in Laravel

Time:05-03

in a Laravel project I want to add a section inside another section I've tried with a @yield but didn't worked. and now I have this code:

@section('form')
  <form>MY FORM</form>
@endsection

and I put it inside this:

@extends('layouts.app')
@section('content')
 <body class: my page
   @include('form')
 </body>
@endsection

but when it loads I only see what 'content' has but not the @include() part.

CodePudding user response:

You don't need to put @section('form') on your form.blade.php . Here's a simple example:

//index.blade.php
@extends('layouts.app')
@section('content')
    <body > 
       @include('form')
    </body>
@endsection

On the Form element

    <form>MY FORM</form>

If you do this, here's what output will look like:

<body > 
   <form>MY FORM</form>
</body>

CodePudding user response:

@extends('layouts.app')
@section('content')
 <body class: my page
  @yield('form')
 </body>
@endsection

In Form Blade

@extends('index')
@section('form')
 @parent
 <form>MY FORM</form>
@endsection

Try like this

  • Related