Thank you for waiting
Please check this example if you want to create a custom attribute with the code.
For your case, please check these instructions.
The editable
parameter is required to make attributes editable in forms.
The filterable
parameter is required if you want to show attributes in the filter form of some model (listing, vendor, etc.). Also, there can be sortable
or searchable
parameters to set to sort or search forms for some models.
edit_field
parameters are required if you want to set the general structure of the attribute. It defines that this attribute contains text, number, or another type of content.
search_field
parameters are required to set the attribute type for a filter, search, or sort form.
The _external
parameter is required if you want to create the independent from some model selectable options for the attribute. So this parameter gives you complete control of selectable attribute options.
$attributes['test_attribute'] = [
'editable' => true,
'filterable' => true,
'display_areas' => [
'view_page_secondary',
],
'edit_field' => [
'label' => 'Test attribute',
'type' => 'select',
'options' => [
'test_1' => 'Test 1',
'test_2' => 'Test 2',
'test_3' => 'Test 3',
],
'_external' => true,
'_order' => 30,
],
'search_field' => [
'label' => 'Test attribute',
'type' => 'select',
'options' => [
'test_1' => 'Test 1',
'test_2' => 'Test 2',
'test_3' => 'Test 3',
],
'_external' => true,
'_order' => 30,
],
];
I hope this will be useful for you. Also, you can check our Developer Docs or Code Snippets collection for additional information or examples