Skip to content
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

feature suggestion: make callbacks configurable #280

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions form.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ type Form struct {
paginator paginator.Model

// callbacks
submitCmd tea.Cmd
cancelCmd tea.Cmd
SubmitCmd tea.Cmd
CancelCmd tea.Cmd

State FormState

Expand Down Expand Up @@ -501,7 +501,7 @@ func (f *Form) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
f.aborted = true
f.quitting = true
f.State = StateAborted
return f, f.cancelCmd
return f, f.CancelCmd
}

case nextFieldMsg:
Expand All @@ -517,7 +517,7 @@ func (f *Form) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
submit := func() (tea.Model, tea.Cmd) {
f.quitting = true
f.State = StateCompleted
return f, f.submitCmd
return f, f.SubmitCmd
}

if f.paginator.OnLastPage() {
Expand Down Expand Up @@ -586,8 +586,8 @@ func (f *Form) View() string {

// Run runs the form.
func (f *Form) Run() error {
f.submitCmd = tea.Quit
f.cancelCmd = tea.Quit
f.SubmitCmd = tea.Quit
f.CancelCmd = tea.Quit

if len(f.groups) == 0 {
return nil
Expand Down