data does not appear on the form when editing a repeater

When clicking Edit, the form does not show the input fields. I'm using Repeater. When creating a record, it works normally. Remembering that I am registering in two related tables.
No description
No description
8 Replies
rg.block
rg.block5mo ago
I am assuming your create code is inside the Createxxxx.php file under the Pages directory. Do you have the repeater code inside your form method in your resource code? The edit form gets created from that section or by the specific code you might have inside your panel resource edit page.
MoreiraME2
MoreiraME25mo ago
My creation code is inside the Resource. But my Edit page has nothing. What do I need to change on the edit page so that the values appear on the form? Below is my Resource Form code and the edit page
No description
No description
toeknee
toeknee5mo ago
ensure the repeater field 'quanity' is cast to array in the model.
MoreiraME2
MoreiraME25mo ago
I'm using a Model has Many as a relational table. @toeknee
No description
toeknee
toeknee5mo ago
Please provide all the code for the repeater. It should be cas 'Relationship'
MoreiraME2
MoreiraME25mo ago
public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Repeater::make('product_point_sale') ->label('') ->schema([ Forms\Components\Fieldset::make('Informações do produto | Estoque | Preço') ->schema([ Forms\Components\Select::make('product_id') ->label('Produto') ->placeholder('Selecione um produto') ->options( Product::all() ->mapWithKeys(fn ($product) => [$product->id => $product->name]) ->toArray() ) ->required(), Forms\Components\Select::make('point_sale_id') ->label('Ponto de Venda') ->placeholder('Selecione um ponto de venda') ->options( PointSale::all() ->mapWithKeys(fn ($pointSale) => [$pointSale->id => $pointSale->name]) ->toArray() ) ->required(), Money::make('price') ->label('Preço de venda') ->required() ->default(0),
... Forms\Components\TextInput::make('quantity') ->label('Quantidade') ->required() ->default(0) ->mask('9999999999'), Forms\Components\TextInput::make('minimum_stock') ->label('Estoque mínimo') ->default(0) ->required() ->mask('9999999999'), Forms\Components\Toggle::make('is_active') ->label('Ativar o produto no ponto de venda'), ]) ]) ->addActionLabel('Adicionar produto') ]) ->columns(1); } this is my Create Form
toeknee
toeknee5mo ago
You shoudl have ->relationship() for your repeater if it's loading from a releationship. It's it;s loading from a column, then you need to cast it to array.