Skip to content

Commit

Permalink
Merge pull request #346 from codeconsole/order-except
Browse files Browse the repository at this point in the history
Support order and except attributes simultaneously
  • Loading branch information
sbglasius authored Sep 5, 2024
2 parents 970ee8b + 29ceb58 commit 3a49947
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
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

0 comments on commit 3a49947

Please sign in to comment.