to-bool

The to-bool operation turns a value into true or false.

Use it when the other side expects a real boolean rather than text, and when you want a clean yes or no to branch on later.

It changes the type, not just the look of the value. A JSON request then carries true rather than "true" or 1.

What comes out

The words true and false are understood as what they say. The string "true" becomes true and the string "false" becomes false. This is a PalDock addition, not standard PHP behaviour, and it exists because those two strings are what forms and APIs actually send.

Everything else follows PHP’s own rules, where a handful of values count as false and the rest count as true.

These become false:

  • false, already a boolean
  • 0, the integer zero
  • 0.0, the float zero
  • "0", the string containing a zero
  • "", an empty string
  • [], an empty list
  • nothing at all

Everything else becomes true, including:

  • any number other than zero, positive or negative
  • any non-empty string, including "0.0" and "no"
  • any list with something in it, even a list containing a zero
  • any object

The catch

"0" is the only non-empty string that becomes false. Everything else with a character in it is true.

That means a field filled in as "no", "off" or "nope" becomes true, which is the opposite of what it says. If your values are words rather than flags, do not use to-bool. Use set value with a condition for each value, so you decide what maps to what.

Watch the empty case too. A field nobody filled in becomes false, which reads as an explicit no rather than as a missing answer. When the difference matters, handle the empty case separately with do-not-send.

An empty list is false and a list holding a single zero is true, which surprises people the first time.

When you need it

Consents and checkboxes are the usual reason. A form checkbox arrives as text and the advertiser wants a boolean.

It is also worth doing before a condition that branches on the value, so you are comparing a real boolean rather than whatever text happened to arrive.

Settings

The operation takes no parameter. Set the source and the condition, choose to-bool, and there is nothing else to fill in.

Reference

Apart from the two words above, the conversion follows PHP’s rules for casting to boolean. See PHP: Converting to boolean.

Insights that
helps you grow

  • Release notes 2026/08/14
    This was a big one. We went through roughly 200 pages of our knowledge base and rewrote the whole thing. Clearer structure, consistent terminology, and…
  • Release notes 2026/07/31
    What’s new in PalDock? A lot of this month went into things you won’t see directly – query optimisation, indexing, and general tuning under the…
  • Free Affiliate tracking software
    Many companies (inlcuding YOU) search for free affiliate tracking software because they want to launch an affiliate program without committing to expensive monthly fees. The…