Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sharp Laravel Package

code16/sharp

Code-driven CMS framework for Laravel (PHP 8.3+/Laravel 11+). Build admin/CMS sections with a clean UI and strong DX: CRUD with validation, search/sort/filter, bulk or custom commands, and authorization—no front-end code required, data-agnostic.

View on GitHub
Deep Wiki
Context7

AutocompleteList

Class: Code16\Sharp\Form\Fields\SharpFormAutocompleteListField

This one may seem a little strange. The goal is to build a List with only one field in each item: an Autocomplete.

First let's see a use case: imagine you want to handle a list of winners by selecting them in a big list of Players, for which a remote Autocomplete is the best choice (otherwise you could have opted for a Tags Field).

You can in fact define the list as this:

SharpFormAutocompleteListField::make('winners')
        ->setLabel('Winners')
        ->setItemField(
            SharpFormAutocompleteRemoteField::make('item')
                ->setRemoteEndpoint('/players')
                // [...]
        )
);

::: tip The key of the Autocomplete, item here, could be anything you want, as soon you stay consistent in the buildFormLayout() part. :::

But why can't we use a classic List for this? Well, the model->winners relation is N-N, here (belongsToMany), but Lists are meant to handle 1-N relationships (hasMany). Here we want one field, the Autocomplete, to represent the whole item object.

Configuration

Configuration is the same as the classic List, except for:

setItemField(SharpFormAutocompleteRemoteField $field)

You can use this function instead of addItemField, since items of AutocompleteList have only one field.

addItemField(SharpFormField $field)

This method is an alias for setItemField(), meaning that you can only pass an Autocomplete, and it can only be called once.

Formatter

toFront

Well, you must provide an array or Collection (same as for a List, see related documentation) of models with at least attributes designated by templates for the Autocomplete (see related documentation).

formFront

Returns the selected item id.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle