BuggerSee
BuggerSee
FFilament
Created by BuggerSee on 9/17/2023 in #❓┊help
Mask is getting applied twice sometimes?
Hello guys, I currently have a strange problem. It looks like sometimes (maybe at the first loading) the mask gets applied twice and this is impacting the user experience a lot unfortunately. My InputField is a custom TextInput
7 replies
FFilament
Created by BuggerSee on 8/7/2023 in #❓┊help
Add custom rule to custom input
Hey all, I have a custom input that is working perfectly, but I want to add a custom rule set. Currently my working code is like this:
OrcidInput::make('orcid')
->rules(['required', new OrcidChecksum])
->columnSpan(6)
->required(),
OrcidInput::make('orcid')
->rules(['required', new OrcidChecksum])
->columnSpan(6)
->required(),
I want to add this rules set to my OrcidInput.php class, so i don't need to repeat the rule everytime i create another OrcidInput. Current OrcidInput:
class OrcidInput extends TextInput
{
//@TODO: add validation logic incl. checksum for last character
protected string $view = 'forms.components.orcid-input';

public function getLabel(): string|Htmlable|null
{
return 'Full ORCID iD';
}
public function hasMask(): bool
{
return true;
}

public function getMask(): ?Mask
{
$mask = new Mask();

$mask->pattern('****-****-****-****');

return $this->evaluate($mask, [
'mask' => app(TextInput\Mask::class),
]);
}
}
class OrcidInput extends TextInput
{
//@TODO: add validation logic incl. checksum for last character
protected string $view = 'forms.components.orcid-input';

public function getLabel(): string|Htmlable|null
{
return 'Full ORCID iD';
}
public function hasMask(): bool
{
return true;
}

public function getMask(): ?Mask
{
$mask = new Mask();

$mask->pattern('****-****-****-****');

return $this->evaluate($mask, [
'mask' => app(TextInput\Mask::class),
]);
}
}
4 replies
FFilament
Created by BuggerSee on 8/3/2023 in #❓┊help
Custom Input use masking. (Money)
Hello, I want to create a custom input for money values. I just want to move this mask to the MoneyInput class, so i have less repeating code. Do i need to change the getMask function in order to do this?
MoneyInput::make('total_income')
->label('Total Income')
->prefix('$')
->mask(fn (TextInput\Mask $mask) => $mask
->numeric()
->thousandsSeparator(',')
->decimalSeparator('.')
->decimalPlaces(2)
)
->numeric()
->required(),
MoneyInput::make('total_income')
->label('Total Income')
->prefix('$')
->mask(fn (TextInput\Mask $mask) => $mask
->numeric()
->thousandsSeparator(',')
->decimalSeparator('.')
->decimalPlaces(2)
)
->numeric()
->required(),
This doesn't work:
class MoneyInput extends TextInput
{
public function getMask(): ?Mask
{
$mask = new Mask();

$mask->numeric()
->thousandsSeparator(',')
->decimalSeparator('.')
->decimalPlaces(2);

return $mask;
}
}
class MoneyInput extends TextInput
{
public function getMask(): ?Mask
{
$mask = new Mask();

$mask->numeric()
->thousandsSeparator(',')
->decimalSeparator('.')
->decimalPlaces(2);

return $mask;
}
}
7 replies
FFilament
Created by BuggerSee on 7/27/2023 in #❓┊help
Wizard Steps, Create Record doesn't save Relationship
6 replies
FFilament
Created by BuggerSee on 6/30/2023 in #❓┊help
Display value of Pivot Table
Hello, I'm currently looking for a better and more performant solution to display a pivot table attribute in my relationManager. It is working right now and using formatStateUsing() but it is doing a lot of DB queries as you might see i use the SponsorType::find() function. SponsorsRelationManager.php
public static function table(Table $table): Table
{
return $table
->columns([
ImageColumn::make('logo_url')
->label('Logo')
->circular()
,
TextColumn::make('name')
->searchable()
->sortable(),
TextColumn::make('country')
->searchable()
->sortable(),
TextColumn::make('sponsor_type_id')
->label('Type')
// Show the name of the sponsor type instead of the ID
->formatStateUsing(function (string $state) {
return SponsorType::find($state)->name;
})
->searchable()
->sortable(),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
ImageColumn::make('logo_url')
->label('Logo')
->circular()
,
TextColumn::make('name')
->searchable()
->sortable(),
TextColumn::make('country')
->searchable()
->sortable(),
TextColumn::make('sponsor_type_id')
->label('Type')
// Show the name of the sponsor type instead of the ID
->formatStateUsing(function (string $state) {
return SponsorType::find($state)->name;
})
->searchable()
->sortable(),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
12 replies
FFilament
Created by BuggerSee on 4/25/2023 in #❓┊help
Set value of Component TextArea in FormAction
Hello, how can i change the value of a TextArea when a button is pressed? Currently have this code in the class that extends CreateRecord but the ->value() function doesnt work: $forms = $this->getForms(); $form = Arr::first($forms); $sqlComponent = $form->getComponents()[0]; $textArea = $sqlComponent->getChildComponents()[1]; $translatedSql = "translated"; $textArea->value($translatedSql);
55 replies