Field is required CSV Importer
Hi, I keep getting the error "field is required", when using requiredMapping() on the CSV importer, although I specify a field.
Anyone has an idea how this comes?
22 Replies
Also the fields won't map automatically with the CSV, for some weird reason
Same issue here, did you have any luck fixing this?
I'm seeing this in console
livewire.js?id=a27c4ca2:347 Uncaught TypeError: Cannot read properties of null (reading 'name')
double checked the csv, looks fine, I even did a dd in resolveRecord after taking the required selections out of the getColumns, that returned the correct array..
documentation says
use Filament\Actions\Imports\ImportColumn;
public function getColumns(): array
{
but when you generate the importer it does a public static function.. weird.did you map them during the import?
yep, the selections are there
but in the console
You have to click on it and map it
let's see your code
Yes update to latest version it has been fixed yesterday
I still get the same issue - what did you update?
Sorry for late reply,
class ProviderImporter extends Importer
{
protected static ?string $model = Provider::class;
public static function getColumns(): array
{
return [
ImportColumn::make('name')
->label('Name')
->requiredMapping()
->rules(['required', 'max:255']),
ImportColumn::make('logoUrl')
->rules(['max:255']),
ImportColumn::make('network_type')
->rules(['max:255']),
// ImportColumn::make('country')
// ->relationship(resolveUsing: function ($state) {
// return Country::where('name', $state)->first()?->id;
// })
];
}
public function resolveRecord(): ?Provider
{
return Provider::firstOrNew([
'name' => $this->data['Name'],
]);
return new Provider();
}
Note: I commented out the relationship column just to show that I'm not doing anything complicated
updated to v3.2.33 and still having the same issue unfortunatelydin you run npm
npm run dev?
Yep, npm run build then npm run dev
csv should just be UTF-8 encoding right?
Yes
dd($this->data);
in resolveRecord after removing the requiredMapping and rules for required
array:7 [โผ // app\Filament\Imports\ProviderImporter.php:35
"ID" => "174"
"Name" => "Vodafone Albania"
"Logo url" => ""
"Network type" => "4g"
"Country" => "Albania"
"Created at" => "2024-02-08 03:48:26"
"Updated at" => "2024-02-08 03:59:41"
]
What is your error?
console says
livewire.js?id=a27c4ca2:347 Uncaught TypeError: Cannot read properties of null (reading 'name')
I did upgrade from filament 2 when 3 came out, if that makes a differenceWhat happends if you update to: https://github.com/filamentphp/filament/releases/tag/v3.2.34
GitHub
Release v3.2.34 ยท filamentphp/filament
What's Changed
adding header to sidebar dropdown by @atmonshi in #11384
Add mask to TextInputColumn by @rappasoft in #11386
v3.2.33: Fix installing Filament without filament/filament due to m...
Same issue
On 3.2.34
same issue ๐ฆ
Any updates on this we still have same issue?
bump ๐
our issue was joshembling/image-optimizer
causing the issue! for all who may come across it.!!
I have this package as well, thank you!
๐