Chandra Wibowo
Chandra Wibowo

Reputation: 13

Laravel backpack, how to set addColumn

How to set addColumn type => select, with option value="1" not value="name"

This is my code :

$this->crud->addColumn([
            // 1-n relationship
            'label'     => "Unit",
            'type'      => "select",
            'name'      => 'measurement_id',
            'entity'    => 'measurement',
            'attribute' => "name",
            'model'     => "App\Models\Measurement",
        ]);

HTML result

<option value="Name">Name</option>

I want set option value by id,

<option value="1">Name</option>

Upvotes: 1

Views: 1658

Answers (1)

Castro Alhdo
Castro Alhdo

Reputation: 291

Be sure you want to adding a column and not a field. If it's a field you should write.

$this->crud->addField([
        // 1-n relationship
        'label'     => "Unit",
        'type'      => "select",
        'name'      => 'measurement_id',
        'entity'    => 'measurement',
        'attribute' => "name",
        'model'     => "App\Models\Measurement",
    ]);

Upvotes: 1

Related Questions