Array input name #11

Closed
erinther opened this Issue Jun 30, 2011 · 5 comments

Comments

Projects
None yet
3 participants

In my models I have: customer: {
name: String,
phone: String,
contact: String,
email: {
type: String,
index: { unique: false},
validate: /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/,
},

nI can@t defin a field like this:
...
title: fields.string({required: true}),
customer: {
email: fields.email(),
name: fields.string(),
}

I got error.. how can i fix it?

Collaborator

ljharb commented May 4, 2012

Perhaps you're looking for:
...
title: fields.string({required: true}),
'customer[email]': fields.email(),
'customer[name]': fields.string(),
...

?

i tried:
..
"contact['name']" : fields.string()
..

but when i try to bind data: form.bind(req.body)

the respective values does not bind on these fields.

Any suggestions?

Collaborator

ljharb commented Jul 3, 2012

What about "contact[name]" ? I've never seen quotes used in form names, even with the nested bracket notation.

already tried too, does not work

Collaborator

ljharb commented Jul 8, 2012

After looking into it, basically forms doesn't currently support nested field names. When it does, the proper solution will be to allow you to do exactly what you tried in your initial post.

ljharb added a commit that referenced this issue Feb 12, 2013

ljharb added a commit that referenced this issue Mar 4, 2013

ljharb added a commit that referenced this issue Mar 18, 2013

ljharb added a commit that referenced this issue Mar 22, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment