[GH-ISSUE #1101] cannot use textView (variable of type *tview.Box) as tview.FormItem value in argument to tview.NewForm() #799

Open
opened 2026-03-04 01:07:50 +03:00 by kerem · 1 comment
Owner

Originally created by @daryl-williams on GitHub (Jun 29, 2025).
Original GitHub issue: https://github.com/rivo/tview/issues/1101

I am trying to write my first tview app and would like to add a textView that will subsequently get filled in, I would also like to add a border to the textView. If I add the textView to the form using the AddTextView command this works however I do not see how to add a border to the textView using this method. If I try to add the textView using the AddFormItem command as demonstrated in multiple web examples I get the followng error:

cannot use textView (variable of type *tview.Box) as tview.FormItem value in argument to tview.NewForm()

So my question is what it is the correct way to add a textView with a border to a Form, It really is rather confusing. Any help would be much appreciated.

Best Regards,

Daryl

Originally created by @daryl-williams on GitHub (Jun 29, 2025). Original GitHub issue: https://github.com/rivo/tview/issues/1101 I am trying to write my first tview app and would like to add a textView that will subsequently get filled in, I would also like to add a border to the textView. If I add the textView to the form using the AddTextView command this works however I do not see how to add a border to the textView using this method. If I try to add the textView using the AddFormItem command as demonstrated in multiple web examples I get the followng error: `cannot use textView (variable of type *tview.Box) as tview.FormItem value in argument to tview.NewForm()` So my question is what it is the correct way to add a textView with a border to a Form, It really is rather confusing. Any help would be much appreciated. Best Regards, Daryl
Author
Owner

@rivo commented on GitHub (Aug 27, 2025):

I don't get that error message:

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	form := tview.NewForm().
		AddDropDown("Title", []string{"Mr.", "Ms.", "Mrs.", "Dr.", "Prof."}, 0, nil).
		AddInputField("First name", "", 20, nil, nil).
		AddInputField("Last name", "", 20, nil, nil).
		AddTextArea("Address", "", 40, 0, 0, nil)
	textView := tview.NewTextView().SetSize(4, 40).SetLabel("Notes")
	textView.SetBorder(true)
	form.AddFormItem(textView)
	form.AddCheckbox("Age 18+", false, nil).
		AddPasswordField("Password", "", 10, '*', nil).
		AddButton("Save", nil).
		AddButton("Quit", func() {
			app.Stop()
		})
	form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft)
	if err := app.SetRoot(form, true).EnableMouse(true).EnablePaste(true).Run(); err != nil {
		panic(err)
	}
}
<!-- gh-comment-id:3228728653 --> @rivo commented on GitHub (Aug 27, 2025): I don't get that error message: ```go package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() form := tview.NewForm(). AddDropDown("Title", []string{"Mr.", "Ms.", "Mrs.", "Dr.", "Prof."}, 0, nil). AddInputField("First name", "", 20, nil, nil). AddInputField("Last name", "", 20, nil, nil). AddTextArea("Address", "", 40, 0, 0, nil) textView := tview.NewTextView().SetSize(4, 40).SetLabel("Notes") textView.SetBorder(true) form.AddFormItem(textView) form.AddCheckbox("Age 18+", false, nil). AddPasswordField("Password", "", 10, '*', nil). AddButton("Save", nil). AddButton("Quit", func() { app.Stop() }) form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft) if err := app.SetRoot(form, true).EnableMouse(true).EnablePaste(true).Run(); err != nil { panic(err) } } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#799
No description provided.