[英]Edit Fields Not working; not updating, and sending empty array to backend
I am using Laravel version 9.41 and Nova 4. I can delete records, however it appears that on the frontend/JavaScript side of things my form fields are not having their contents captured and sent back to the server.我正在使用 Laravel 版本 9.41 和 Nova 4。我可以删除记录,但是在前端/JavaScript 方面,我的表单字段似乎没有捕获其内容并将其发送回服务器。 My action_events table shows [ ] empty arrays as what is being sent.
我的 action_events 表显示 [ ] 空 arrays 作为正在发送的内容。
I have spent a good four or five hours googling and checking that my Resources, field names etc. are all spelled correctly.我花了四五个小时在谷歌上搜索并检查我的资源、字段名称等是否拼写正确。 I also see no error messages.
我也没有看到任何错误消息。 Each time I get the green success message, "This has been updated."
每次我收到绿色成功消息时,“已更新”。 or whatever.
管他呢。
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class Post extends Resource
{
/**
* The model the resource corresponds to.
*
* @var class-string<\App\Models\Post>
*/
public static $model = \App\Models\Post::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'id';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id',
'text'
];
/**
* Get the fields displayed by the resource.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function fields(NovaRequest $request)
{
return [
ID::make('id', 'id')->sortable(),
Text::make('text', 'text')->sortable()
];
}
Someone gave me the answer elsewhere: inn my Post model, after deleting/commenting out the lines in the screenshot below: all worked fine.有人在别处给了我答案:inn my Post model,删除/注释掉下面截图中的行后:一切正常。 There was no reason to define the following properties.
没有理由定义以下属性。 They are not part of any Eloquent conversion.
它们不是任何 Eloquent 转换的一部分。 I did not need the following (in App/Models/Post):
我不需要以下内容(在 App/Models/Post 中):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.