Logo Text Blaze

  • Docs
  • Community
  • Documentation

    No search results

    Text Blaze

    Loading...

    Data Blaze

    Loading...

    Community Forums

    Loading...
Add to Chrome –  It's Free! Go to Dashboard ›
Commands

{formtoggle}

Summary: Creates a toggle switch that can enable or disable a block of text.
Sample Usage
Dear Friend,

{formtoggle: name=Thank You; default=no}Thank you so much for your message.{endformtoggle}

[Message Contents]

{formtoggle: name=Call Me; default=yes}Please call anytime.{endformtoggle}

-Joe
_

Settings


Setting NameTypeDescription
General Form Settings
nametextName used for labels and data bindings.
default–The default value for the form field.
formatterfunctionFormats the value of the field before snippet insertion.
General Command Settings
trimyes/no/left/rightIf yes whitespace is removed before and after the command. If left, only whitespace to the left is removed. If right, only whitespace to the right is removed.

To learn more about form commands and their capabilities, see the forms guide.

Toggles allow you to selectively hide and show parts of your snippet. If a toggle is unchecked, everything between the {formtoggle} and {endformtoggle} commands will be hidden.

This command is similar to the {if} command, but the {if} command uses formulas to dynamically include or exclude content.

The optional {endformtoggle} command

The {endformtoggle} is optional and if omitted, yes or no will be shown when the snippet is inserted based on the value of the toggle's value.

You may change the output using the optional formatter setting. The formatter setting takes a function where the first parameter is the value of the toggle, either yes or no.

The following example illustrates this (you will need to copy it into Text Blaze and trigger the snippet to see it in practice).

Using a Custom Toggle Formatter
Survey Questions

Age: {formmenu: 0-20; 20-40; 40-60; 60-80; 80+}

Marital Status: {formtoggle: name=Married; formatter=(value) -> "Married" if value else "Not Married"}
_

The above snippet will output Married instead of yes, or Not Married if the toggle's value is no.

Click here to learn more about the formatter function available to you.

{formtoggle} and whitespace

With multiline commands like {if} or {formtoggle} you generally want to have trailing or leading new lines to be within the command. This can be counterintuitive as it's generally not how you would write the snippet by default.

This prevents multiple extraneous newlines from showing up in your snippets. Here's an example demonstrating the issue:

Handling whitespace with formtoggle
Incorrect Way If you disable any of these formtoggle commands, you will get empty lines where they were.

{formtoggle: name=Married}You are married{endformtoggle} {formtoggle: name=Young}You are young{endformtoggle} {formtoggle: name=Tall}You are tall{endformtoggle}

A Better Way The formtoggle commands have their newline within the toggle.

{formtoggle: name=Married}You are married {endformtoggle}{formtoggle: name=Young}You are young {endformtoggle}{formtoggle: name=Tall}You are tall{endformtoggle}
_

To learn more about why this happens and how Text Blaze manages whitespace in your snippets, see the whitespace guide.

  • Guides
    • Quick Start
    • Sharing Snippet Folders
    • Dynamic Commands
    • Date and Time
    • Autopilot
    • Forms
    • Formulas
    • Rules & Validation
    • Tidying Whitespace
    • Lists
    • Teams and Organizations
  • Tutorial Videos
  • Academy
    • Intro to commands
  • Showcase
  • Frequently Asked Questions
  • Formula Reference
  • Dynamic Commands
    • Using Dynamic Commands
    • {=} (Formula Command)
    • {click}
    • {clipboard}
    • {cursor}
    • {error}
    • {formdate}
    • {formmenu}
    • {formparagraph}
    • {formtext}
    • {formtoggle}
    • {if}
    • {import}
    • {key}
    • {link}
    • {note}
    • {repeat}
    • {site}
    • {snippet}
    • {time}
    • {user}
    • {wait}
  • Connected Snippets
    • Connected Snippets Overview
    • {image}
    • {urlload}
    • {urlsend}
    • {dbselect}
    • {dbinsert}
    • {dbupdate}
    • {dbdelete}
  • Command Packs
    • Capitalize
    • Gmail
    • LinkedIn
    • Randomize

About

Plans and Pricing
Sharing Snippets
Text Blaze for Business
Forms
Autopilot
Dynamic Commands
Command Packs
Text Blaze for Windows

Support

Get Started with Text Blaze
Contact Us
Documentation
Community Forum
Blog

Solution for

Teams
Customer Support
Recruiters
Education
Healthcare
Sales
Property Managers

Other

Privacy Policy
Terms of Service
Open Source Licenses
Affiliate
© 2023 Blaze Today Inc