-
Notifications
You must be signed in to change notification settings - Fork 649
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
Adding a default value to selects #216
Labels
Comments
bump? |
I have tried your code, I had to make some adjustments to get the test running but it seems to work. Maybe you createTitleMap function works differently? var monthsOfYear = ["Jan", "Feb"];
var years = ['2003', '2004'];
$scope.schema = {
type: 'object',
title: 'Payment Information',
required: [
'expirationDate'
],
properties: {
expirationDate: {
title: 'Expiration Date',
type: 'object',
properties: {
month: {
title: 'Month',
type: 'string',
enum: monthsOfYear // Array of valid Months
},
year: {
title: 'Year',
type: 'string',
enum: years // Array of valid Years
}
}
}
}
};
var createTitleMap = function(x, arr)
{
var result = [];
result.push({name: x, value:"?"});
for(var i = 0; i < arr.length; i++)
result.push({name: arr[i], value:arr[i]});
return result;
};
$scope.form = [
{
key: 'expirationDate',
notitle: true,
items: [
{
key: 'expirationDate.month',
type: 'select',
titleMap: createTitleMap('MONTH', monthsOfYear), // Prepends 'MONTH'
}, {
key: 'expirationDate.year',
type: 'select',
titleMap: createTitleMap('YEAR', years), // Prepends 'YEAR'
}
]
}
];
$scope.model = {
expirationDate: {
month: '?', // '?' is the key associated to the defaults
year: '?' // '?' is the key associated to the defaults
}
}; |
I'm going to close this issue. I feel like it is probably user error lol |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am creating a month select and need a default value of 'MONTH' which should be invalid. I have tried setting the model to a value that is declared in the
titleMap
but not theenum
. Validation works as expected but I can't get a default value to show in the select. Is there something I am missing?The text was updated successfully, but these errors were encountered: