What additional steps do I need to take set the date-picker's initial-value to the user's birthday using the viv.self library? Is this the best place to handle this? Currently I am setting the default to 30 Years Prior.
render {
date-picker {
// Default Date -30 Years (viv.self Birthday Option)
initial-value ("subtractDuration(now().date, 'P30Y')")
restrictions {
// allow selection 80 Years Ago
min-allowed ("subtractDuration(now().date, 'P80Y')")
// to allow selection 18 Years Ago
max-allowed ("subtractDuration(now().date, 'P18Y')")
}
}
}
match-pattern
to achieve this.In your Action, create an additional attribute of type
time.Date
(or a concept withrole-of
oftime.Date
) to hold the Birthday.Heres how the code would look like.
The BirthDate concept used in the code above looks like this
Your input-view will look like this. This defines a
match-pattern
that is invoked whenever we need an input view for BirthDate and that BirthDate is functioning as an input back to the action.Checkout match patterns here: https://bixbydevelopers.com/dev/docs/dev-guide/developers/customizing-plan.match-patterns