Instance Method インスタンスメソッド

submitScope(_:)

Prevents submission triggers originating from this view to invoke a submission action configured by a submission modifier higher up in the view hierarchy.

Declaration 宣言

func submitScope(_ isBlocking: Bool = true) -> some View

Parameters パラメータ

isBlocking

A Boolean that indicates whether this scope is actively blocking submission triggers from reaching higher submission actions.

Discussion 議論

Use this modifier when you want to avoid specific views from initiating a submission action configured by the onSubmit(of:_:) modifier. In the example below, the tag field doesn’t trigger the submission of the form:


Form {
    TextField("Username", text: $viewModel.userName)
    SecureField("Password", text: $viewModel.password)


    TextField("Tags", text: $viewModel.tags)
        .submitScope()
}
.onSubmit {
    guard viewModel.validate() else { return }
    viewModel.login()
}

See Also 参照

Submission