gpt4 book ai didi

grails - 更新或更改Grails中的用户数据表单

转载 作者:行者123 更新时间:2023-12-02 15:24:57 25 4
gpt4 key购买 nike

我必须在Grails中编写一个更新或更改用户数据表单。这是我的表格:

<g:form class="form-signin" controller="VisitorSpace">
<label for="login" class="sr-only">Login</label>
<g:textField id="login" class="form-control" name="login" placeholder="login" required="" autofocus=""/>
<label for="firstName" class="sr-only">Your name</label>
<g:textField id="firstName" class="form-control" name="firstName" placeholder="Your name" required="" type="text"/>
<label for="lastName" class="sr-only">Your lastname</label>
<g:textField id="lastName" class="form-control" name="lastName" placeholder="Your lastname" required="" type="text"/>

<label for="inputEmail" class="sr-only">e-mail</label>
<g:textField id="inputEmail" class="form-control" name="email" placeholder="e-mail" required="" autofocus="" data-translatable-string="Email address" type="email"/>
<label for="inputPassword" class="sr-only">Password</label>
<g:passwordField id="inputPassword" class="form-control" name="password" placeholder="Password" required="" data-translatable-string="Password"/>

<label for="confirmPassword" class="sr-only">Confirm password</label>
<g:passwordField id="confirmPassword" class="form-control" name="controlPassword" placeholder="Confirm password" required="" data-translatable-string="Password"/>
<g:actionSubmit value="Commit change" action="updateUserData" class="btn btn-lg btn-primary btn-block">Commit change</g:actionSubmit>
</g:form>

旧数据必须显示在字段中,因此必须将其从数据库发送到加载 View 表单的那一刻。我知道,有可能调用所需的 Controller 方法来执行此操作,并且必须在加载 View 表单之前或同时调用此方法。但是该怎么做呢?

最佳答案

value属性与要从 Controller 获取的当前数据一起添加到输入字段元素中。这就是您要的吗?

<g:textField id="lastName" value="${objectInstance.lastName}" ... />

关于grails - 更新或更改Grails中的用户数据表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29379624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com