Pedroesca
passing data between forms
field in headerData:
Placeholder::make('total')
->columnSpan(2)
->hiddenLabel()
->live()
->content(fn () => new HtmlString('
<div style="text-align: right;">
<div style="font-size: 20px; color: #a9a9a9;">Subtotal</div>
<div style="font-size: 35px; font-weight: bold;">' . $this->cartTotal . '</div>
</div>
'))
->afterStateUpdated(function (Set $set) {
//$set('./total', $this->cartTotal);
$this->footerData['subtotal'] = $this->cartTotal;
}),
Once the process is finished, the user presses "confirm" and a "footerForm" modal is displayed, where I have the input "subtotal":
public function footerForm(Form $form): Form
{
return $form
->model(Sale::class)
->statePath('footerData')
->schema([
TextInput::make('subtotal')
->columnSpanFull()
->live()
->disabled()
->dehydrated(true),
This input must contain the same value as the placerholder "total"
7 replies
FooterActions method not present in Filament\Forms\Components\Section;
Now it updated correctly, but it started to show me the error "Undefined type 'Filament\Tables\Columns\TextColumn'.intelephense(P1009)" in ->columns([
TextColumn::make('status')) of my resources
12 replies
beforeSave whith relations
La única forma que encontré para solucionar fue:
1. en afterFill (EditSale)
protected function afterFill(): void
{
if ($this->record->draft == 1) {
return; // Salir del método si la venta está en borrador
}
$this->originalDetails = $this->record->products->toArray();
session()->put('originalDetails', $this->record->products->toArray());
}
2. y en beforeSave recupero el registro original
protected function beforeSave(): void
{
if ($this->record->draft === 1) {
return; // Salir del método si la venta está en borrador
}
$this->originalDetails = session()->get('originalDetails', []);
foreach ($this->originalDetails as $detail){
// Obtener el producto relacionado
$product = Product::find($detail['product_id']);
if ($product){
//REVERTIR STOCK
$stockActual = $product->stock_current;
11 replies