mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #483] Feature Request: GetValue on FormItem #351
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#351
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @t1nfoil on GitHub (Aug 1, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/483
Hi rivo.
First off, thanks for this great library.
I have a lot of form's that I add input fields to, drop downs, etc, using the AddXXXX receiver methods (AddInputTextField, AddDropDown) etc. One thing I've noticed is that I can't seem to pull out the selected default value when a user doesn't change the fields value:
tmpForm.AddInputField("API Username", apiUserName, 256, nil, func(text string) { configStruct.ApiUsername = text })This works well if the user changes the value in the input field, as the function will copy the text over to the configStruct.ApiUsername, however using the AddXXXX receivers, there does not appear to be a way to get the text out when referencing by label name:
`apiUsernameField := tmpForm.GetFormItemByLabel("API Username")
apiUsername := apiUsernameField.GetXXXXXXX <-- no methods to get value
`
I can get the field label "API Username" but there does not appear to be a way to get the value out of the FormItem interface?
The workaround I have found to work is to use the tview.NewInputField() method, and then assign everything to a variable, but for large forms it really adds a lot of clutter.
@rivo commented on GitHub (Sep 15, 2020):
The
FormIteminterface is for all form items. So the type of "value" is not the same for the different form items. (It may be a "bool" for checkboxes or a "string" for input fields.) If you want to access an input field's value directly, you'll have to do a cast:Please let me know if this answers your question.
@rivo commented on GitHub (Nov 17, 2020):
If you still require information, please open another issue and reference this one.