Skip to content

Example of Form Component #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/Http/Controllers/Admin/IconCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ protected function setupListOperation()
$this->crud->addClause('where', 'created_at', '<=', $value['to']);
}
});

$this->crud->removeButton('update');
$this->crud->addButton('line', 'inline_edit_icon', 'view', 'crud::buttons.inline_edit_icon', 'beginning');
}

protected function setupCreateOperation()
Expand Down
41 changes: 40 additions & 1 deletion resources/views/admin/new-in-v7.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
@extends(backpack_view('blank'))

@php
// Add the form widget to the 'after_content' section of the widgets array
$widgets['after_content'][] = [
'type' => 'div',
'class' => 'row',
'content' => [ // widgets
[
'type' => 'form',
'wrapper' => [
'class' => 'col-md-12 mt-3',
],
'controller' => '\App\Http\Controllers\Admin\PetShop\SkillCrudController',
'content' => [
'header' => 'Create Skill', // optional
'body' => 'This form should make it easy to create a new skill.<br><br>', // optional
],
]
]
];
@endphp

@section('content')

<!-- Heading for Datagrid component -->
<div class="row g-2 align-items-center">
<div class="col text-white">
<div class="col">
<div class="page-pretitle">Components</div>
<h2 class="page-title">Datagrid</h2>
<p class="mt-2 mb-2">Show the most important info about an Eloquent entry, anywhere you want.</p>
Expand Down Expand Up @@ -56,4 +77,22 @@

@include('admin.partials.datatable-examples')

<!-- Heading for Form component -->
<div class="row g-2 align-items-center mt-3">
<div class="col">
<div class="page-pretitle">Components</div>
<h2 class="page-title">Dataform</h2>
<p class="mt-2 mb-2">Show a form for an Eloquent entry, anywhere you want.</p>
</div>
<div class="col-auto ms-auto d-print-none">
<div class="btn-list">
<span class="d-none d-sm-inline">
<a href="#" class="btn btn-primary"> See docs </a> <!-- TODO: link to final docs -->
</span>
</div>
</div>
</div>

@include('admin.partials.dataform-examples')

@endsection
92 changes: 92 additions & 0 deletions resources/views/admin/partials/dataform-examples.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<div class="row">
<div class="col-md-12">
<div class="card card-stacked mt-3">
<div class="card-header">
<h3 class="card-title">
Create Invoice

<i class="la la-info-circle text-muted"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="Showing the form needed to create an Invoice, with all configuration pulled directly from InvoiceCrudController."></i>
</h3>
<div class="card-actions">
<div class="dropdown">
<a href="#" class="btn-action dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="icon icon-1">
<path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path>
<path d="M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path>
<path d="M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path>
</svg>
</a>
<div class="dropdown-menu dropdown-menu-end" style="">
<a class="dropdown-item" href="#">See demo code</a> <!-- TODO: link to demo code -->
<a class="dropdown-item" href="#">See docs</a> <!-- TODO: link to final docs -->
</div>
</div>
</div>
</div>
<div class="card-body">

<x-bp-form controller="\App\Http\Controllers\Admin\PetShop\InvoiceCrudController" />

</div>
</div>
</div>
</div>

<div class="row">
<div class="col-md-6">
<div class="card mt-3">
<div class="card-header">
<h3 class="card-title">
Quick Add Tag
</h3>
</div>
<div class="card-body bg-light">

<x-backpack::form id="quickAddTag"
controller="\Backpack\NewsCRUD\app\Http\Controllers\Admin\TagCrudController" />

</div>
</div>
</div>

<div class="col-md-6">
<div class="card mt-3">
<div class="card-header">
<h3 class="card-title">
Other Quick Actions
</h3>
</div>

<div class="card-body">
<button type="button" class="btn btn-primary" data-toggle="modal" data-bs-toggle="modal"
data-target="#addOwnerForm" data-bs-target="#addOwnerForm">
Add Owner
</button>
<x-backpack::form-modal id="addOwnerForm"
controller="\App\Http\Controllers\Admin\PetShop\OwnerCrudController" title="Add Owner" />

<button type="button" class="btn btn-primary" data-toggle="modal" data-bs-toggle="modal"
data-target="#addPetForm" data-bs-target="#addPetForm">
Add Pet
</button>
<x-backpack::form-modal id="addPetForm"
controller="\App\Http\Controllers\Admin\PetShop\PetCrudController" title="Add Pet" />

<button type="button" class="btn btn-primary" data-toggle="modal" data-bs-toggle="modal"
data-target="#addProductForm" data-bs-target="#addProductForm">
Add Product
</button>
<x-backpack::form-modal id="addProductForm"
controller="\App\Http\Controllers\Admin\ProductCrudController" title="Add Product" />
</div>
</div>

@include('backpack.theme-tabler::inc.commercial')
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<a href="#" data-toggle="modal" data-bs-toggle="modal" data-target="#myForm{{$entry->getKey()}}" data-bs-target="#myForm{{$entry->getKey()}}" class="btn btn-sm btn-link">
<i class="la la-edit"></i> <span>{{ trans('backpack::crud.edit') }}</span>
</a>

<x-backpack::form-modal
id="myForm{{$entry->getKey()}}"
controller="App\Http\Controllers\Admin\IconCrudController"
modalTitle="Update Icon"
:action="url($crud->route.'/'.$entry->getKey().'')"
:formRouteOperation="url($crud->route.'/'.$entry->getKey().'/edit')"
method="PUT"
refreshDatatable="true"
operation="update"
/>
13 changes: 7 additions & 6 deletions resources/views/vendor/backpack/theme-tabler/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// notice we use Widget::make() to add widgets as content (not in a group)
Widget::make()
->type('progress')
->class('card mb-3')
->class('card mb-1')
->statusBorder('start') // start|top|bottom
->accentColor('success') // primary|secondary|warning|danger|info
->ribbon(['top', 'la-user']) // ['top|right|bottom']
Expand All @@ -48,7 +48,7 @@
// but we need to use onlyHere() or remove() at the end
Widget::add()
->type('progress')
->class('card mb-3')
->class('card mb-1')
->statusBorder('start') // start|top|bottom
->accentColor('danger') // primary|secondary|warning|danger|info
->ribbon(['top', 'la-bell']) // ['top|right|bottom']
Expand All @@ -63,7 +63,7 @@
Widget::make()
->group('hidden')
->type('progress')
->class('card mb-3')
->class('card mb-1')
->statusBorder('start') // start|top|bottom
->accentColor('info') // primary|secondary|warning|danger|info
->ribbon(['top', 'la-star']) // ['top|right|bottom']
Expand All @@ -76,7 +76,7 @@
// if you prefer defining your widgets as arrays
Widget::make([
'type' => 'progress',
'class'=> 'card mb-3',
'class'=> 'card mb-1',
'statusBorder' => 'start', // start|top|bottom
'accentColor' => 'warning', // primary|secondary|warning|danger|info
'ribbon' => ['top', 'la-lock'], // ['top|right|left|bottom', 'la-xxx']
Expand Down Expand Up @@ -151,7 +151,7 @@
'close_button' => true, // show close button or not
];

$widgets['before_content'][] = [
$widgets['after_content'][] = [
'type' => 'div',
'class' => 'row',
'content' => [ // widgets
Expand Down Expand Up @@ -263,12 +263,13 @@
'header' => 'Line Chart - Frappe', // optional
// 'body' => 'This chart should make it obvious how many new users have signed up in the past 7 days.<br><br>', // optional
]
],
]
]
];
@endphp

@section('content')

{{-- In case widgets have been added to a 'content' group, show those widgets. --}}
@include(backpack_view('inc.widgets'), [ 'widgets' => app('widgets')->where('group', 'content')->toArray() ])
@endsection
Loading