У меня есть компонент Livewire OpportunityQuote, в структуре которого есть Repeater, например:
Код: Выделить всё
class OpportunityQuote extends Component implements HasForms {
public function form(Form $form): Form
{
return $form
->schema([
Repeater::make('quote_services_repeater')
->label('Serviços Adicionados')
->itemLabel(function (array $state) {
return new HtmlString(
view('filament.components.service-repeater-item')
->with('state', $state)
->render()
);
})
->schema(function () {
return [
Livewire::make(OpportunityQuoteItem::class),
];
})
->statePath('quote_services'),
]);
}
public function updateItems($item, $index)
{
$this->items[$index] = $item;
$this->form->fill([
'quote_services' => $this->items,
]);
}
Код: Выделить всё
class OpportunityQuoteItem extends Component
{
public ?array $item = [];
public function mount($item)
{
$this->item = $item;
}
public function render()
{
return view('livewire.opportunity.quote-item');
}
}
Если мы посмотрим на метод itemLabel, то увидим, что по умолчанию он имеет $state, который представляет текущую строку, поэтому вы можете настроить заголовок.
Но как мне сделать это для моих записей и тела элемента?
Подробнее здесь: https://stackoverflow.com/questions/791 ... -component
Мобильная версия