shebaoting
shebaoting
FFilament
Created by shebaoting on 5/7/2024 in #❓┊help
In Form Builder, how to listen for input from forms?
Package Form builder Package Version 3.0 How can we help you? In Form Builder, how to listen for input from forms? I want to trigger a method when listening to text-input or Select content change, what should I do? For example, in the following code, I want to trigger methods or events when the content of the TextInput and Select in the Builder changes, what should I do?
class Add extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;

public OrderModel $order;
public $productsData;

public function render()
{
return view('livewire.company.order.add');
}

public function addOrderAction(): Action
{
return Action::make('addOrder')
->form([
Textarea::make('notes')
->rows(3),
Builder::make('paybacks')
->blocks([
Builder\Block::make('heading')
->schema([
TextInput::make('amount')->numeric()->required(),
Select::make('status')
->options([
'pending' => 'pending',
'completed' => 'completed',
])->native(false)->required(),
])->columns(3),
// ...
]),
FileUpload::make('contract')->multiple(),
])
->action(function (array $data, OrderModel $record): void {

})
->mutateFormDataUsing(function (array $data): array {

});
}
}
class Add extends Component implements HasForms, HasActions
{
use InteractsWithActions;
use InteractsWithForms;

public OrderModel $order;
public $productsData;

public function render()
{
return view('livewire.company.order.add');
}

public function addOrderAction(): Action
{
return Action::make('addOrder')
->form([
Textarea::make('notes')
->rows(3),
Builder::make('paybacks')
->blocks([
Builder\Block::make('heading')
->schema([
TextInput::make('amount')->numeric()->required(),
Select::make('status')
->options([
'pending' => 'pending',
'completed' => 'completed',
])->native(false)->required(),
])->columns(3),
// ...
]),
FileUpload::make('contract')->multiple(),
])
->action(function (array $data, OrderModel $record): void {

})
->mutateFormDataUsing(function (array $data): array {

});
}
}
3 replies
FFilament
Created by shebaoting on 4/23/2024 in #❓┊help
How can I create three navigations based on the same model?
I have a student model. But each student's class is different. I want to use navigation on the left side to distinguish classes. For example, there are three navigations on the left side, namely, Class One, Class Two, and Class Three. Do I need to create three filament-resources based on the student model? Is there a better way?
3 replies
FFilament
Created by shebaoting on 11/5/2023 in #❓┊help
How to show associated attachment model images in forms?
Currently there is the IdentityVerification model. IdentityVerification and Attachment are one-to-many relationships. I want to display the Attachment of the current message in the resource edit page of IdentityVerification, what should I do?
public function attachments()
{
return $this->hasMany(Attachment::class, 'model_id');
}
public function attachments()
{
return $this->hasMany(Attachment::class, 'model_id');
}
Section::make('info')
->description('info')
->aside()
->schema([
Repeater::make('attachments')
->relationship()
->schema([
FileUpload::make('paths')->image()
])
->addable(false)
->deletable(false)
])
Section::make('info')
->description('info')
->aside()
->schema([
Repeater::make('attachments')
->relationship()
->schema([
FileUpload::make('paths')->image()
])
->addable(false)
->deletable(false)
])
paths is the field associated with the model attachment. It is the address of an image. I want it to show up. I don't know how to do it.
1 replies