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 for parameterizing choice fields by the current entry #364

Closed
wants to merge 2 commits into from

Conversation

kenegozi
Copy link
Contributor

This opens up contextual select tags, e.g. cascading selects.

e.g to create a cascading set of 'state' and 'city' fields, you can now do that:

 nga.field('state', 'choice').choices(states),
 nga.field('city', 'choice').choices(function(entry) {
     return cities.filter(function(city) { return city.state === entry.values.state;} );
 })

given

 var states = [ { value:'WA', label:'Washington'}, ... ];
 var cities = [ { value:'Bellevue', label: 'Bellevue', state: 'WA'} , ... ];

@fzaninotto
Copy link
Member

Great idea!

Although there are a couple more uses of Field.choices, in ChoicesField for instance. Could you also update these ones?

Also, would you mind adding a mention of the new syntax in the README?

@kenegozi
Copy link
Contributor Author

Good catch. I included ChoicesField, added a few tests/specs (for Choice and Choices), and a mention in the readme.

@jpetitcolas
Copy link
Contributor

👍

@jpetitcolas
Copy link
Contributor

Can you rebase on master, now that tests are fixed?

@fzaninotto
Copy link
Member

Superseded by #398

@fzaninotto fzaninotto closed this Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants