有没有人对此有任何想法?我有一个模板_contact.gsp呈现为视图右侧的一列。以下是其代码:
<div id="contact-${contactType.id}" class="contact" style="${contactType.isPrimary == 1 ? '' : 'display: none;'}">
<g:hiddenField name="contact-${contactType?.id}.id" value="${contact?.id}"/>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.organization.name"/></content>
<content tag="label.for">contact-${contactType?.id}.organizationName</content>
<g:form id="form-org" action="search">// this tag is not rendered
<input type="text" id="Company" value="search for..." name="Company" class="field">
</g:form>
</g:applyLayout><div>
<label style="visibility:hidden" for="PRIVATE" class="lb">-------------------------------------</label><a onclick="$('#form-org').submit()" style="display:inline"><img src="/jbilling/images/icon-search.gif"></a></div>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.first.name"/></content>
<content tag="label.for">contact-${contactType?.id}.firstName</content>
<g:textField class="field" name="contact-${contactType?.id}.firstName" value="${contact?.firstName}" />
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.last.name"/></content>
<content tag="label.for">contact-${contactType?.id}.lastName</content>
<g:textField class="field" name="contact-${contactType?.id}.lastName" value="${contact?.lastName}" />
</g:applyLayout>
<g:applyLayout name="form/text">
<content tag="label"><g:message code="prompt.phone.number"/></content>
<content tag="label.for">contact-${contactType?.id}.phoneCountryCode</content>
<span>
<g:textField class="field" name="contact-${contactType?.id}.phoneCountryCode" value="${contact?.phoneCountryCode}" maxlength="3" size="2"/>
-
<g:textField class="field" name="contact-${contactType?.id}.phoneAreaCode" value="${contact?.phoneAreaCode}" maxlength="5" size="3"/>
-
<g:textField class="field" name="contact-${contactType?.id}.phoneNumber" value="${contact?.phoneNumber}" maxlength="10" size="8"/>
</span>
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.email"/></content>
<content tag="label.for">contact-${contactType?.id}.email</content>
<g:textField class="field" name="contact-${contactType?.id}.email" value="${contact?.email}" />
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.address1"/></content>
<content tag="label.for">contact-${contactType?.id}.address1</content>
<g:textField class="field" name="contact-${contactType?.id}.address1" value="${contact?.address1}" />
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.address2"/></content>
<content tag="label.for">contact-${contactType?.id}.address2</content>
<g:textField class="field" name="contact-${contactType?.id}.address2" value="${contact?.address2}" />
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.city"/></content>
<content tag="label.for">contact-${contactType?.id}.city</content>
<g:textField class="field" name="contact-${contactType?.id}.city" value="${contact?.city}" />
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.state"/></content>
<content tag="label.for">contact-${contactType?.id}.stateProvince</content>
<g:textField class="field" name="contact-${contactType?.id}.stateProvince" value="${contact?.stateProvince}" />
</g:applyLayout>
<g:applyLayout name="form/input">
<content tag="label"><g:message code="prompt.zip"/></content>
<content tag="label.for">contact-${contactType?.id}.postalCode</content>
<g:textField class="field" name="contact-${contactType?.id}.postalCode" value="${contact?.postalCode}" />
</g:applyLayout>
<g:applyLayout name="form/select">
<content tag="label"><g:message code="prompt.country"/></content>
<content tag="label.for">contact-${contactType?.id}.countryCode</content>
<g:select name="contact-${contactType?.id}.countryCode"
from="${CountryDTO.list()}"
optionKey="code"
optionValue="${{ it.getDescription(session['language_id']) }}"
noSelection="['': message(code: 'default.no.selection')]"
value="${contact?.countryCode}"/>
</g:applyLayout>
<g:applyLayout name="form/checkbox">
<content tag="label"><g:message code="prompt.include.in.notifications"/></content>
<content tag="label.for">contact-${contactType?.id}.include</content>
<g:checkBox class="cb checkbox" name="contact-${contactType?.id}.include" checked="${contact?.include}"/>
</g:applyLayout>
</div>
当我在firefox中运行此代码时,视图呈现正常,除了缺少表单标记。我在firebug中检查了这个,当单击按钮时没有响应。firebug显示源代码如下: 在firefox中呈现的视图源,对应于包含表单标记的applyLayout标记
<div class="row"> //notice this;form is absent
<label for="contact-20.organizationName">Organization Name</label>
<div class="inp-bg ">
<input type="text" class="field" name="Company" value="search for..." id="Company">
</div>
由于从form标签到div标签的转换,我的按钮无效。 Plz有助于防止这种转变...
答案 0 :(得分:2)
好吧,g:form
不会由Firefox呈现,而是由服务器中的Grails呈现,它将向浏览器发送HTML form
。但你应该知道浏览器会忽略嵌套的表单,我猜这就是这种情况。
Grails可能 呈现标记,浏览器忽略它,因为它在另一种形式中。
您可以通过右键单击页面并选择View Page Source
来查看查看源的情况,这将显示Grails的确切输出。