Comments (6)
Попробуйте переименовать связь attributes
например на categoryAttributes
from moonshine.
<select class="form-select" x-data="select('')" data-search-enabled="data-search-enabled" data-remove-item-button="data-remove-item-button" value="[1]" id="attributes" name="attributes[]" multiple="multiple" x-on:change="onChangeField($event)">
<form class="form" method="POST" x-data="formBuilder(`crud`, [])" x-init="init({"whenFields":[],"reactiveUrl":""})" action="http://127.0.0.1/admin/resource/category-resource/crud/1" enctype="multipart/form-data" x-id="['form']" :id="$id('form')">
from moonshine.
Спасибо за issue! Я проверил у себя и не обнаружил никаких ошибок, думаю дело в чем то еще, пришлите ресурс полностью
from moonshine.
CategoryResource:
<?php
declare(strict_types=1);
namespace App\MoonShine\Resources;
use Illuminate\Database\Eloquent\Model;
use App\Models\Category;
use MoonShine\Resources\ModelResource;
use MoonShine\Fields\ID;
use MoonShine\Fields\Relationships\BelongsTo;
use MoonShine\Fields\Relationships\BelongsToMany;
use MoonShine\Fields\Select;
use MoonShine\Fields\Slug;
use MoonShine\Fields\Text;
/**
* @extends ModelResource<Category>
*/
class CategoryResource extends ModelResource
{
protected string $model = Category::class;
protected string $title = 'Категории';
public string $column = 'name';
public function indexFields(): array
{
return [
ID::make()->sortable(),
Select::make('Статус', 'status')
->options(Category::$statuses)
->default('new'),
Text::make('Название', 'name'),
Slug::make('Код', 'slug'),
BelongsTo::make('Родитель', 'parent', resource: new CategoryResource())
->nullable(),
];
}
public function formFields(): array
{
return [
ID::make()->sortable(),
Select::make('Статус', 'status')
->options(Category::$statuses)
->default('new'),
Text::make('Название', 'name'),
Slug::make('Код', 'slug')->from('name'),
BelongsTo::make('Родитель', 'parent', resource: new CategoryResource())
->nullable(),
BelongsToMany::make('Атрибуты', 'attributes', resource: new AttributeResource())
// ->asyncSearch()
// ->selectMode(),
];
}
public function detailFields(): array
{
return [
ID::make()->sortable(),
Select::make('Статус', 'status')
->options(Category::$statuses)
->default('new'),
Text::make('Название', 'name'),
Slug::make('Код', 'slug'),
BelongsTo::make('Родитель', 'parent', resource: new CategoryResource())
->nullable(),
BelongsToMany::make('Атрибуты', 'attributes', resource: new AttributeResource()),
];
}
public function rules(Model $item): array
{
return [];
}
}
AttributeResource:
<?php
declare(strict_types=1);
namespace App\MoonShine\Resources;
use Illuminate\Database\Eloquent\Model;
use App\Models\Attribute;
use MoonShine\Resources\ModelResource;
use MoonShine\Fields\ID;
use MoonShine\Fields\Select;
use MoonShine\Fields\Text;
/**
* @extends ModelResource<Attribute>
*/
class AttributeResource extends ModelResource
{
protected string $model = Attribute::class;
protected string $title = 'Атрибуты';
public string $column = 'name';
public function indexFields(): array
{
return [
ID::make()->sortable(),
Text::make('Название', 'name'),
Text::make('Код', 'code'),
Select::make('Тип', 'type')
->options(Attribute::$types)
->default('text'),
];
}
public function formFields(): array
{
return [
ID::make()->sortable(),
Text::make('Название', 'name'),
Text::make('Код', 'code'),
Select::make('Тип', 'type')
->options(Attribute::$types)
->default('text'),
];
}
public function detailFields(): array
{
return [
ID::make()->sortable(),
Text::make('Название', 'name'),
Text::make('Код', 'code'),
Select::make('Тип', 'type')
->options(Attribute::$types)
->default('text'),
];
}
public function rules(Model $item): array
{
return [];
}
}
from moonshine.
Покажите пожалуйста как выглядит html тег select, скопируйте именно код селекта а не врапперов и у основной формы будут дата атрибуты x-init вот его тоже покажите
from moonshine.
Это сработало
from moonshine.
Related Issues (20)
- QueryTag::make()->translatable() HOT 3
- HasMany::make()->creatable() не обрабатывает reactive поля HOT 1
- Installation error HOT 1
- Limit items in HasMany HOT 2
- Поле MorphMany не подхватывает карту классов при создании новых записей
- При использовании поля JSON в качестве отношения в методы ...aplay() приходят не верные данные. HOT 3
- Отсутствие перевода для сообщений Choices.js
- TableBulder throws TypeError when using Paginator HOT 5
- Не понятно активно ли поле при переходе по Tab на поля Select, BelongsTo, BelongsToMany->selectMode() HOT 2
- Добавить clickAction на HasMany
- Iterable.js refactoring
- Images slider
- Async delete for Json,File,Image
- Websockets
- ShowWhen
- The issue lies with the checkboxes for bulk actions
- Markdown field
- Возможность перехода на детальную страницу ресурса через поля BelongToMany или MorphToMany
- Добавить функцию nullable к полю JSON HOT 1
- Передача значения поля Date в другое поле с использованием reactive() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moonshine.