You could start by giving us an example. What form, what input, and what output and where (database?)
Composer update causes Malformed UTF-8 characters, possibly incorrectly encoded
After updating my filament 3 app I am getting "Malformed UTF-8 characters, possibly incorrectly encoded", when I submit a form. Struggling really long already to get this solved, but I don't know how anymore. The problem is I don't know where to start to debug? Maybe someone could help?
Thanks for your answer. I already tried to comment out different lines of code, but no success finding the error.
This form is affected.
<?php
namespace App\Filament\Resources;
use App\Enums\AcidityRegulators;
use App\Enums\Color;
use App\Enums\Countries;
use App\Enums\GasesAndPackingGases;
use App\Enums\Ingredients;
use App\Enums\PreservativesAndAntioxidants;
use App\Enums\Stabilisers;
use App\Enums\Status;
use App\Enums\Type;
use App\Enums\Wines;
use App\Enums\YeastMannoproteins;
use App\Filament\Resources\QrCodeResource\Pages;
use App\Models\QrCode;
use App\Models\User;
use App\Service\Ingredient\FormCalculationService;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\CheckboxColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class QrCodeResource extends Resource
{
protected static ?string $model = QrCode::class;
protected static ?string $navigationIcon = 'heroicon-o-qr-code';
public static function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make(__('Ingredients'))
->schema([
Select::make('user_id')
->required()
->searchable()
->getSearchResultsUsing(fn (string $search): array => User::where('name', 'like', "%{$search}%")->limit(50)->pluck('name', 'id')->toArray())
->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name)
->options(User::limit(50)->pluck('name', 'id')->toArray()),
TextInput::make('set_paid')
->label('Bezahlt gesetzt')
->type('date'),
Fieldset::make('ingredients')
->relationship('ingredient')
->label(__('Ingredients'))
->schema([
FileUpload::make('photo')
->imageEditor()
->image()
->directory('photo')
->disk('public')
->previewable()
->maxSize(1024 * 5)
->maxFiles(1)
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/jpg'])
->openable()
->columnSpanFull(),
Select::make('wines')
->label('Wines')
->options(Wines::class)
->maxItems(15)
->multiple()
->required(),
TextInput::make('vintage')
->type('date'),
Select::make('type')
->options(Type::class)
->selectablePlaceholder(true),
Select::make('color')
->default(Color::White)
->options(Color::class)
->selectablePlaceholder(false)
->required(),
TextInput::make('measure_date')
->type('date'),
TextInput::make('name_wine')
->maxLength(255)
->string(),
TextInput::make('alcohol')
->label(__('Alcohol content Vol %'))
->required()
->numeric()
->minValue(0)
->maxValue(100),
TextInput::make('residual_sugar')
->required()
->numeric()
->minValue(0)
->maxValue(1000),
TextInput::make('acid')
->required()
->numeric()
->minValue(0)
->maxValue(10000),
TextInput::make('shelf_life')
->numeric()
->minValue(1)
->maxValue(10000),
Select::make('country_code')
->required()
->options(Countries::class)
->default(Countries::Austria)
->selectablePlaceholder(false),
TextInput::make('region')
->string()
->maxValue(255),
TextInput::make('quantity')
->numeric()
->required()
->minValue(1)
->maxValue(10000),
TextInput::make('verification_number')
->string()
->maxValue(255),
TextInput::make('kj')
->nullable()
->requiredWith('kcal')
->numeric()
->minValue(0)
->maxValue(100000),
TextInput::make('kcal')
->nullable()
->requiredWith('kj')
->numeric()
->minValue(0)
->maxValue(100000),
TextInput::make('carbohydrates')
->required()
->numeric()
->minValue(0)
->maxValue(100),
TextInput::make('sugar')
->required()
->numeric()
->minValue(0)
->maxValue(100),
TextInput::make('fat')
->required()
->numeric()
->minValue(0)
->maxValue(100),
TextInput::make('saturated_fat')
->required()
->requiredWith('fat')
->numeric()
->minValue(0)
->maxValue(100),
TextInput::make('protein')
->required()
->numeric()
->minValue(0)
->maxValue(100),
TextInput::make('salt')
->required()
->numeric()
->minValue(0)
->maxValue(100),
Select::make('ingredients')
->options(Ingredients::class)
->selectablePlaceholder(false)
->live()
->multiple(),
Select::make('preservatives_and_antioxidants')
->options(PreservativesAndAntioxidants::class)
->live()
->multiple(),
Select::make('stabilisers')
->label('Cross Rent Period')
->live()
->options(Stabilisers::class)
->multiple(),
Select::make('acidity_regulators')
->options(AcidityRegulators::class)
->live()
->multiple(),
Select::make('gases_and_packing_gases')
->options(GasesAndPackingGases::class)
->live()
->multiple(),
Select::make('yeast_mannoproteins')
->options(YeastMannoproteins::class)
->multiple()
->live(),
Textarea::make('ingredients_text')
->nullable()
->maxLength(10000)
->rows(10)
->columnSpanFull(),
Textarea::make('description')
->nullable()
->maxLength(10000)
->rows(10)
->columnSpanFull(),
])
->mutateRelationshipDataBeforeCreateUsing(function ($data, Get $get, FormCalculationService $formCalculationService) {
$data['user_id'] = $get('user_id');
$data['kj'] = $formCalculationService->calculateKj($data);
$data['kcal'] = $formCalculationService->calculateKcal($data);
return $data;
}),
])->columns(2),
Wizard\Step::make('QR Code')
->schema([
...\LaraZeus\Qr\Facades\Qr::getFormSchema('url', 'options', '', false),
]),
])->columnSpanFull(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('user.name')
->label(__('Name'))
->sortable(),
TextColumn::make('ingredient.wines')
->label(__('Wines'))
->sortable(),
TextColumn::make('ingredient.type')
->label(__('Type'))
->sortable(),
TextColumn::make('ingredient.vintage')
->label(__('Year'))
->dateTime('d.m.Y H:i')
->sortable(),
TextColumn::make('ingredient.measure_date')
->label(__('Value measured on'))
->dateTime('d.m.Y H:i')
->sortable(),
CheckboxColumn::make('active')
->label(__('Active'))
->sortable(),
TextColumn::make('paid')
->label(__('Status'))
->getStateUsing(fn ($record) => ($record->isPaid() || $record->isSetPaid()) ? Status::Paid->getLabel() : Status::Unpaid->getLabel())
->badge()
->color(fn (string $state): string => match ($state) {
Status::Paid->getLabel() => 'success',
Status::Unpaid->getLabel() => 'danger',
})
->sortable(),
TextColumn::make('created_at')
->label(__('Created'))
->dateTime('d.m.Y H:i')
->sortable(),
])
->filters([
//
])
->actions([
Tables\Actions\Action::make(__('Preview'))
->action(function ($record) {
return redirect()->to(route('pages.show', $record->id));
}),
Tables\Actions\Action::make(__('Download'))
->url(fn ($record) => route('filament.admin.resources.qr-codes.download', $record->id)),
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListQrCodes::route('/'),
'create' => Pages\CreateQrCode::route('/create'),
'view' => Pages\ViewQrCode::route('/{record}'),
'edit' => Pages\EditQrCode::route('/{record}/edit'),
'download' => Pages\Download::route('/{record}/download'),
];
}
}
What do you mean with where database? I am using a mysql database
Found out its this here ...\LaraZeus\Qr\Facades\Qr::getFormSchema('url', 'options', '', false),
but I dont know how to resolve it.
@ronok i am asking where you are seeing the malformed data. In the database? Or in an input field? What are you typing and what comes out malformed?
@Sinnbeck The package is the problem, because it has a different data structure (array looks not the same anymore) after updating it. Thanks for your help!
Please or to participate in this conversation.