$user->username, 'is_admin' => $user->is_admin ? 'on' : '', ]); } parent::__construct($state); } public function pageTitle(): string { return "管理画面 - ユーザ {$this->user->username} 編集"; } public function redirectUrl(): string { return $this->routeParser->urlFor('admin_user_list'); } protected function submitLabel(): string { return '保存'; } /** * @return list */ protected function items(): array { return [ new FormItem( name: 'username', type: 'text', label: 'ユーザ名', isDisabled: true, ), new FormItem( name: 'is_admin', type: 'checkbox', label: '管理者', ), ]; } /** * @return array{user: User} */ public function getRenderContext(): array { return [ 'user' => $this->user, ]; } public function submit(): void { $is_admin = $this->state->get('is_admin') === 'on'; $this->userRepo->update( $this->user->user_id, is_admin: $is_admin, ); } }