Conor Hambuch
Select field allowHtml does not render <img> tags.
I have a select field which i want to render images and descriptions, so I have to use custom html, but img tags are not rendered.
The field:
Forms\Components\Select::make('product')->options(array_map(function($product){
return $this->productToHtml($product);
}, $products))->allowHtml()
and the helper function:
public function productToHtml($product){
return '<img src="' . $product['imageUrls'][0] . '" alt="No image" ></img>' .
$product["name"] ;
}
(images are from external sources)
This code renders only the product names.
Edit: I checked it and all html classes are removed from the rendered code.
4 replies
mask+ real time validation
If I have real time validation with:
public function updated($propertyName)
{
$this->validateOnly($propertyName);
}
And an input mask for a TextInput, e.g.
Forms\Components\TextInput::make('weight')-
->mask('9')
->numeric()
->integer()
->required()
->minValue(1) ->maxValue(6), Then the validation runs on page load and of course is invalid because of 'required' validator and the unfilled TextInput. If I have no mask, then validators run only if user starts to fill the input. (And the integer validator is not enough for me, because it allows dot and comma somehow...)
->minValue(1) ->maxValue(6), Then the validation runs on page load and of course is invalid because of 'required' validator and the unfilled TextInput. If I have no mask, then validators run only if user starts to fill the input. (And the integer validator is not enough for me, because it allows dot and comma somehow...)
5 replies
Use repeatable entry to display a non-database array
I have an array, let's say
$people = [0 => ['name' => 'John', 'age' => 5], 1 => ['name' => 'Carl', 'age' => 10]]
and I would like to use RepeatableEntry to display this data like this
RepeatableEntry::make('people')
->state($people)
->schema([
TextEntry::make('name'),
TextEntry::make('age'),
])
This recognizes the size of the array, but does not find the attributes named in make method. So it just displayes 2 blank rows.
Is there a way to make this work?
2 replies
Translation in panel providers when registered in Provider.
I tried to register a MenuItem with __('Help') label, but tranlsation service is not registered yet (Target class [translator] does not exist.). It is weird to me that it worked until v3.0.13, but not after that.
4 replies
Choose Panel when testing
I'm wondering how can I choose panel when I'm testing, because the example given in the documentation works only on the admin panel. getUrl function gives APP_URL/admin.
Livewire::test(ResourceName::getUrl('index'))
->assertFormExists();.
This gives /admin/panelname/resource-name, but the page is at /panelname/resource-name.
If I make it like this: AvailableParcelsResource::getUrl('index', [], true, 'panelname'), it cannot find Route [filament.panelname.resources.resource-name.index].
9 replies