Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support order and except attributes simultaneously #346

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ class FormFieldsTagLib {
List<PersistentProperty> properties

if (attrs.order) {
def orderBy = getList(attrs.order)
if (attrs.except) {
throwTagError('The [except] and [order] attributes may not be used together.')
orderBy = orderBy - getList(attrs.except)
}
def orderBy = getList(attrs.order)
properties = orderBy.collect { propertyName ->
fieldsDomainPropertyFactory.build(domainClass.getPropertyByName(propertyName))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,17 @@ class AllTagSpec extends AbstractFormFieldsTagLibSpec implements TagLibUnitTest<

}

@Issue('https://github.com/grails3-plugins/fields/issues/9')
void 'order attribute and except attribute are mutually exclusive'() {
@Issue('https://github.com/gpc/fields/issues/347')
void 'allow order and except attributes'() {
given:
views["/_fields/default/_field.gsp"] = '|${property}|'
views["/_fields/default/_wrapper.gsp"] = '${widget}'

when:
applyTemplate('<f:all bean="personInstance" except="password" order="name, minor, gender"/>', [personInstance: personInstance])
def output = applyTemplate('<f:all bean="personInstance" except="minor, password" order="name, minor, gender"/>', [personInstance: personInstance])

then:
GrailsTagException e = thrown()
e.message.contains 'The [except] and [order] attributes may not be used together.'
output == '|name||gender|'
}

void "f:all tag supports theme"() {
Expand Down
Loading