Skip to content

Commit

Permalink
feature suggestion: make callbacks configurable (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
abradley2 committed Jun 14, 2024
1 parent 5b41f0b commit d7db017
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit d7db017

Please sign in to comment.