简体   繁体   中英

Playframework forms

I'm creating a form to allow users to edit my objects, but it seems that only the object fields that are editable in the form are available within my controller once the form is submitted. My example is a user object that I present in a form to allow the user to edit the name field, when they submit the form my controller needs to determine if this is a new user or an exiting user. To determine this I check the ID field, but since the ID field is not editable on the form it is null, when I check it in the controller.

Have I missed something?

For this scenario, keep your id has hidden input in template. So that it will be available for you in controller after user hitting form's submit button.

<input type="hidden" name="id" value='@userForm.field("id").value' >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM