我如何更改后背包的选择字段上的选项名称

问题描述 投票:0回答:1

我如何在不更改值的情况下设置选项名称。我的意思是。

使用此代码

$this->crud->addField([
            'name'=>'idtype',
            'label'=>'Tipo de Documento',
            'type'=>'enum'
        ]);

我知道了

<option value="CC">CC</option>

我想得到这个

<option value="CC">Cédula de Ciudadanía</option>
laravel backpack-for-laravel
1个回答
0
投票

您可以尝试使用select_from_array字段类型代替select。此字段类型使您可以显式定义该选择输入的<options>将是:

$this->crud->addField([   // select_from_array
    'name' => 'template',
    'label' => "Template",
    'type' => 'select_from_array',
    'options' => [‘one’ => ‘One’, ‘two’ => ‘Two’],
    'allows_null' => false,
    'default' => 'one',
    // 'allows_multiple' => true, // OPTIONAL; needs you to cast this to array in your model;
]);

注意options参数接受一个数组。您可以手动定义该数组以说出所需的内容,但使数组键的值与ENUM db列可以容纳的值相同。

© www.soinside.com 2019 - 2024. All rights reserved.