Erro na passagem de parâmetro na action Create
16/04/2013 11:39
<g:link class="property-value" controller="valor" action="create" params="[indice: indice?.id]">
def create() {
[valorInstance: new Valor(params)]
}
def create() {
def valorInstance = new Valor()
[valorInstance: valorInstance, indice:params.indice]
}
Valor(indice: params.id)mas precisa ver na sua Domain Valor as regras de validação e preenchimento.
class Indice {
String nome
String sigla
static hasMany = [percMensais: Valor]
String toString(){
"${this.sigla} (${this.nome})"
}
static constraints = {
nome(nullable: false, blank:false, maxSize:50)
sigla(nullable: false, blank:false, maxSize:10)
}
}
class Valor {
Indice indice
Date data
Float percentual
static belongsTo = Indice
String toString(){
"${this.data.format('MM/yyyy')} - ${this.percentual}"
}
static constraints = {
indice(nullable:false, blank:false)
data(nullable:false, blank:false)
percentual(nullable:false, blank:false)
}
}
Para se registrar, clique aqui.