Laravel 8 - 选择特定值时自动更新表单域

Laravel 8 - Automatically update a form field when certain value is selected

我有一辆卡车 table 和一名邮递员 table。两个 table 都具有一对一的关系。一车一邮,一邮一车

postman/create.blade.php 文件中,有一个 HTML 表单,其中包含 truck_numberpostman_numberpostman_namedate_of_operation 待填写由用户。

truck_number 以下拉列表格式显示,每次从卡车 table 创建 truck_number 时,列表都会自动更新。在卡车 table 内,每个 truck_number 都有自己的 date_of_operation.

因此,对于 postman/create.blade.php 文件中的 date_of_operation 字段,我希望当用户选择与其关联的特定 truck_number 时,该值会在同一表单中自动更新。

是否可以在 laravel 中执行此操作而不涉及任何形式的 ajax 或 json?我怎样才能正确实施它?

在向 server.You 发送请求之前,您无法获取该值可以使用 livewire,与 laravel 关联的全栈框架。你可以轻松地做你愿意做的事情。这是文档: https://laravel-livewire.com/docs/2.x/quickstart