PHP code example of ranium / filament-flags-dropdown
1. Go to this page and download the library: Download ranium/filament-flags-dropdown library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ranium / filament-flags-dropdown example snippets
use Ranium\FlagsDropdown\Forms\Components\Fields\FlagsDropdown;
public static function form(Form $form): Form
{
$countries = [
'in' => ['value' => 'IND', 'label' => 'India'],
'us' => ['value' => 'USA', 'label' => 'United States'],
];
return $form
->schema([
// ... Other fields
FlagsDropdown::make('country')
->options($countries), // Chain your field modifiers here
// Other fields
]);
}
use Filament\Pages\Page;
use Filament\Forms\Concerns\InteractsWithForms;
use Ranium\FlagsDropdown\Forms\Components\Fields\FlagsDropdown;
class Settings extends Page
{
use InteractsWithForms;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.settings';
protected function getFormSchema(): array
{
return [
FlagsDropdown::make('language')
->options(['in' => 'Hindi', 'gb' => 'English'])
->onChange($this->doSomething(...)),
];
}
public function doSomething(?string $newValue, ?string $oldValue)
{
// This method will be called whenever the value of the
// dropdown changes in the frontend
}
}