Reputation: 35
I want to access the user info in the result- and input-view to make a message like that "Thanks [Username] for you sharing"
Upvotes: 1
Views: 49
Reputation: 1501
I assume result-view is easy, so I include an example here for input-view.
The challenge here is to render the [username] which is not part of the input value. The solution is to group these two values together with an action.
input-view {
match: IntAge(this) {
to-input: GetStructPerson (action)
}
message {
template ("Enter age of #{value(action.name)}")
}
render {
form {
elements {
number-input {
id (that)
label (Age)
type (IntAge)
}
}
on-submit {
goal: IntAge
value: viv.core.FormElement(that)
}
}
}
}
Action is nothing but a constructor
action (GetStructPerson) {
description (__DESCRIPTION__)
type (Constructor)
collect {
input (name) {
type (TextName)
min (Required) max (One)
}
input (age) {
type (IntAge)
min (Required) max (One)
}
}
output (StructPerson)
}
I think this is the similar render result you want.
Upvotes: 2
Reputation: 795
User information is present in $vivContext which is accessible to the developer in the corresponding javascript file of an Action. One way to achieve what you are trying to do would be to create a hidden property in your structure (called in the result-view) called userName
and use an Action FillUserName
to populate this property.
The following resources will help too. Good luck!
Upvotes: 1