Hidden form input

I have a simple form to create a new task that should include a hidden property for ProjectId (int). However, hidden property doesn't seem to work. Is there any other way to send and save it together with all the other properties filled in by the user when a new object is created?

The only way I can think of is to assign the property before calling a method to save it:

    private async Task HandleValidSubmit()
    {
        projectTask.ProjectId = ProjectId;
        await projectService.CreateProjectTask(projectTask);
    }

This seems to be a valid solution and should work as expected.