How to pass variable to addButtonFromView #1383
Replies: 2 comments 1 reply
-
In Backpack 6.x, the standard signature for However, starting from Backpack v6.7, you can pass parameters to a button view using the fluent button API with the CRUD::button('bulk_send_order')
->stack('bottom')
->view('bulk_send_order')
->position('end')
->parameters(['posts' => \App\Models\Post::all()]); In your Blade file ( <select class="form-select form-control">
<option value="">-- Select Location --</option>
@foreach($parameters['posts'] as $post)
<option value="{{ $post->id }}">{{ $post->title }}</option>
@endforeach
</select> This approach is supported in recent versions of Backpack 6.x, as described in the CRUD buttons can now pass parameters to views update. Summary:
If you use the classic ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: 2. CRUD Operations|Buttons Footnotes |
Beta Was this translation helpful? Give feedback.
-
Hey @smzapp It seems you are trying to build a BulkOperation and want to show dropdown in the modal or something. @php
$posts = \App\Models\Post::all();
@endphp
<select class="form-select form-control">
<option value="">-- Select Location --</option>
@foreach($posts as $post)
<option value="{{ $post->id }}">{{ $post->title }}</option>
@endforeach
</select> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Using laravel backpack, I created a custom blade file named bulk_send_order. Now, When I passed posts, $posts is undefined in blade. I am using "backpack/crud": "^6.7". How to fix this?
CRUD::addButtonFromView(
-- Select Location -- @foreach($posts as $post) {{ $post->title}} @Endforeach'bottom', // stack
'bulk_send_order', // button name
'bulk_send_order', // Blade view name
'end', // position
[ 'posts' => \App\Models\Post::all() ] // data
);
// blade
Beta Was this translation helpful? Give feedback.
All reactions