Set Schema Default Currency Lost Inside Nested Components

I got this infolist for my products view page.
class ProductInfolist
{
public static function configure(Schema $schema): Schema
{
$currency = Currency::defaultCurrency()->value;

return $schema
->inlineLabel()
// ->defaultCurrency($currency) // lost inside Section/Grid
->components([
Grid::make()
->columns(1)
->schema([
TextEntry::make('category.title'),
TextEntry::make('title_bg'),
TextEntry::make('title_en'),
TextEntry::make('quantity')
->numeric(),
TextEntry::make('currency'),
TextEntry::make('price')
->money($currency),
TextEntry::make('price_monthly')
->money($currency),
TextEntry::make('price_three_months')
->money($currency),
TextEntry::make('price_yearly')
->money($currency),
TextEntry::make('price_two_years')
->money($currency),
TextEntry::make('price_three_years')
->money($currency),
]),
class ProductInfolist
{
public static function configure(Schema $schema): Schema
{
$currency = Currency::defaultCurrency()->value;

return $schema
->inlineLabel()
// ->defaultCurrency($currency) // lost inside Section/Grid
->components([
Grid::make()
->columns(1)
->schema([
TextEntry::make('category.title'),
TextEntry::make('title_bg'),
TextEntry::make('title_en'),
TextEntry::make('quantity')
->numeric(),
TextEntry::make('currency'),
TextEntry::make('price')
->money($currency),
TextEntry::make('price_monthly')
->money($currency),
TextEntry::make('price_three_months')
->money($currency),
TextEntry::make('price_yearly')
->money($currency),
TextEntry::make('price_two_years')
->money($currency),
TextEntry::make('price_three_years')
->money($currency),
]),
The money is properly formatted if the text entries are put inside the $schema->components([]) directly, but when nested inside another layout component like Grid or Section, the money() method resolves the $defaultCurrency = 'usd' instead the one I've set on the parent component - the Infolist schema. How do I get rid of those $currency variables I have now?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?