【问题标题】:how to save radion buttons in grails如何在grails中保存单选按钮
【发布时间】:2024-04-27 01:30:01
【问题描述】:

我的班级:

package com

class Cafe {

    String cafeteriasurvey


    static constraints = {

        cafeteriasurvey nullable:true
    }

}

&form.gsp:

<%@ page import="com.Cafe" %>


<style>


h1{

text-align:center;

Color:#680000;

}

h2{

text-align:center;

font-weight:normal;

}

p{

font-style:Arial;

background-color:#b2b2b2;

}

.wrapper{

text-align:center;

}

.save{

text-align:center;

}

</style>

<h1>Cafeteria Survey</h1><br>


<h2 style="Color:#87212e">Caterer:Abhiruchi Caterers</h2><br>


<p>1.How would you rate for overall 'Breakfast' food items?</p><br>


<g:radioGroup name="cafeteriasurvey"


              values="['Muslim', 'Hindu', 'Christian', 'Buddhist']"


              labels="['Muslim', 'Hindu', 'Christian', 'Buddhist']"


              value="${cafeInstance?.cafeteriasurvey}">


    <p>${it.label}: ${it.radio}</p>


</g:radioGroup>

如何保存单选按钮的任何解决方案。

【问题讨论】:

  • 这已经足够接近,甚至不是一个 grails 问题。您会在 html 中使用什么来发布项目?表单 ?具有提交 URL 的表单,因此
    radioButton SUBMIT 按钮然后是
    。在尝试 grails 应用程序之前,请先学习一些基本的 html 内容。

标签: grails grails-2.0 grails-2.4


【解决方案1】:

在控制器中调用名称(params.cafeteriasurvey)。 然后创建新对象。 并调用 object.save() 参考这个 http://docs.grails.org/3.1.1/ref/Tags/radioGroup.html

【讨论】:

    最近更新 更多