commented out $this->crud->setFromDb();
added columns with addColumn
````
public function setup()
{
/*
|--------------------------------------------------------------------------
| CrudPanel Basic Information
|--------------------------------------------------------------------------
*/
$this->crud->setModel('App\Models\ResourceGroupRequest');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/resourcegroup');
$this->crud->setEntityNameStrings('Resource Group Request', 'Resource Group Requests');
/*
|--------------------------------------------------------------------------
| CrudPanel Configuration
|--------------------------------------------------------------------------
*/
// TODO: remove setFromDb() and manually define Fields and Columns
// $this->crud->setFromDb();
$this->crud->addColumn([
'label' => 'Status',
'type' => 'text',
'name' => 'status',
'priority' => 1,
]);
$this->crud->addColumn('ResourceGroupName');
$this->crud->addColumn('Subscription');
$this->crud->addColumn('RequesterEmail');
$this->crud->addColumn('created_at', 'Created');
// add asterisk for fields that are required in ResourceGroupRequestRequest
$this->crud->setRequiredFields(StoreRequest::class, 'create');
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');
$this->crud->addFilter([
'type' => 'simple',
'name' => 'trashed',
'label' => 'Show Deleted Records'
],
false,
function($values)
{
// IF THE FILTER IS ACTIVE
$this->crud->query->onlyTrashed();
});
}
````
Expect to see the 5 columns I specified on all Crud views (index, edit, create)
Index looks great, the table displays just as expected.
'Edit' and 'Add new record' both display no fields, just the submit/cancel buttons.
Read documentation on $this->crud->addColumn
note this works fine if I leave $this->crud-setFromDB() in the code.
latest
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication mediums:
backpack-for-laravel tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
--
Justin Case
The Backpack Robot
For create and Update you have to define fields: https://backpackforlaravel.com/docs/3.4/crud-fields
Columns are only for index 馃槈
Closing this as I just noticed in the documentation that addColumn and addField are actually two distinct things, so it seems it's working as expected.
@tabacitu if you happen to see this, it would be neat if there was a way to set fields and columns from the db independently.
ie
````
//old:
$this->crud->setFromDb();
//new:
$this->crud->setIndexColumnsFromDb();
$this->crud->setFormFieldsFromDb();
````
This would accomplish the same thing, while making the scope of commenting these out clearer.
It also would have the added benefit of allowing a dev to easily create a custom index while relying on setFormFieldsFromDb() for the Create and Update screens.
Thanks!
@tswonke Thanks Thomas! I had _just_ noticed that and was typing a reply as yours came in.
Most helpful comment
For create and Update you have to define fields: https://backpackforlaravel.com/docs/3.4/crud-fields
Columns are only for index 馃槈