Unable to show non numeric primary key in tables?

I have the current schema in
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('busnumber')
->required()
->maxLength(8),
Forms\Components\Select::make('driver_id')
->relationship('driver', 'name')
->required(),
Forms\Components\TextInput::make('model')
->required()
->maxLength(65535)
->columnSpanFull(),
Forms\Components\TextInput::make('maxpax')
->required()
->numeric()
->maxLength(65535)
->columnSpanFull(),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('busnumber')
->required()
->maxLength(8),
Forms\Components\Select::make('driver_id')
->relationship('driver', 'name')
->required(),
Forms\Components\TextInput::make('model')
->required()
->maxLength(65535)
->columnSpanFull(),
Forms\Components\TextInput::make('maxpax')
->required()
->numeric()
->maxLength(65535)
->columnSpanFull(),
]);
}
However, the busnumber seems to print out to 0 on the form. The rest is printing out fine. Could this be because busnumber is a primary key?
Solution:
All we needed is
protected $keyType = 'string';
protected $keyType = 'string';
Jump to solution
8 Replies
BakaPresident
BakaPresident9mo ago
No description
krekas
krekas9mo ago
why would make a primary key that can be entered?
BakaPresident
BakaPresident9mo ago
Isn't it logical to have a primary key when it's unique? Carplate are unique so i don't think there's a problem right?
krekas
krekas9mo ago
primary should be one? unique doesn't need to be primary
BakaPresident
BakaPresident9mo ago
But carplates are unique and only have 1 also right? Should i just change it to numeric then have another field and make it unique?
krekas
krekas9mo ago
don't know how it stored. by i guess it could be just a string
Solution
BakaPresident
BakaPresident9mo ago
All we needed is
protected $keyType = 'string';
protected $keyType = 'string';
aliif
aliif9mo ago
thanks solved my problem