Replies: 2 comments
-
Based on the knowledge sources provided, there doesn't seem to be a built-in option in Backpack to automatically select the first item if there is only one option in select fields like relationship, select2, or select. However, I can provide some information on related functionality and potential workarounds.
$this->crud->addField([
'label' => "Category",
'type' => 'select',
'name' => 'category_id',
'entity' => 'category',
'attribute' => 'name',
'model' => "App\Models\Tag",
'default' => '25'
]);
If you need this specific functionality of auto-selecting the first (and only) option, you might need to implement a custom solution or request this feature from the Backpack team. The current documentation and issues don't mention a built-in way to achieve this exact behavior. ℹ️ 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: Github Issue (closed): Select2 Autofocus Option in Backpack PRO |
Beta Was this translation helpful? Give feedback.
-
Hey @pxpm How do you find this feature? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As the title says, for fields like: relationship, select2, select and so on, add an option to auto select the first item in the list if the list contains only 1 item.
Beta Was this translation helpful? Give feedback.
All reactions