Changeset 896
- Timestamp:
- Sep 20, 2010, 5:17:37 PM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/TemplateEditorController.groovy
r711 r896 503 503 template.fields.add( Integer.parseInt( params.position ), templateField ) 504 504 } 505 template.save(flush:true); 505 506 if (!template.validate()) { 507 response.status = 500; 508 template.errors.each { render it} 509 } 510 template.save(flush:true); 506 511 507 512 def html = g.render( template: 'elements/selected', model: [templateField: templateField, template: template, ontologies: Ontology.list(), fieldTypes: TemplateFieldType.list()] ); -
trunk/grails-app/domain/dbnp/studycapturing/Template.groovy
r883 r896 73 73 // which can co-exist with the same name. See also TemplateField 74 74 // name(unique:['entity']) 75 // workaround:76 name(validator: { value, obj, errors ->77 // 'obj' refers to the actual Template object78 79 // define a boolean80 boolean error = false81 82 if (value && obj.entity) {83 84 // gather all Cars with this particular model85 def entityTemplates = Template.findAllByEntity(obj.entity)86 87 // check if there is already a Template object with this name in that collection88 if (entityTemplates.findAll{it.name.equals(value)}.size() > 0) {89 errors.rejectValue(90 'name',91 'template.UniqueNameViolation',92 [value, obj.entity] as Object[],93 'There already exists a template named {0} for entity {1}'94 )95 error = true96 }97 }98 else {99 // if there is no name or model defined, fail immediately100 error = true101 }102 // got an error, or not?103 if (error) return false104 })105 75 106 76 }
Note: See TracChangeset
for help on using the changeset viewer.