[英]how to add a new input as a dropdown type and with filled default options to laravel jetstream registration form
my need is to add a new input as a dropdown type and with filled default options to laravel.8 jetstream registration form.我需要添加一个新的输入作为下拉类型,并在 laravel.8 jetstream 注册表单中填充默认选项。 my problems are:我的问题是:
I understand this is not a full answer to all of your questions but should help.我知道这不是您所有问题的完整答案,但应该有所帮助。
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
app/Actions/Fortify/CreateNewUser.php
accessing the array.您可以在访问数组的app/Actions/Fortify/CreateNewUser.php
中获取/使用该值。 The following inserts the new value into the database:以下将新值插入数据库:return User::create([
'name' => $input['name'],
'email' => $input['email'],
'car' => $input['cars']),
'password' => Hash::make($input['password']),
'api_token' => Str::random(60),
]);
You will also need to update the app/Models/User.php
Model and add the new value as fillable (and of course have added the field to your User
Model via a migration):您还需要更新app/Models/User.php
Model 并将新值添加为可填写(当然,已通过迁移将该字段添加到您的User
ZA559B87068921EEC05086CE5485E974):
protected $fillable = [
'name',
'email',
'password',
'car',
];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.