# $field->toBool()

Converts the field value into a proper boolean

****

- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/methods.php#L95>

****

```php
$field->toBool(bool $default = false): bool
```

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$default` | `bool` | `false` | Default value if the field is empty |

## Return type

`bool`

This method modifies the existing `$field` object it is applied to and returns it again.

## Aliases

You can use the following aliases for this field method in your template:

- `$field->bool(…)`

## Examples

### Basic usage

```php
<?php if ($page->hasHeader()->toBool()): ?>
<header>
  <!-- Your code here -->
</header>
<?php endif ?>
```

### With default

```php
<?php if ($page->hideHeader()->toBool(true)): ?>
<header>
  <!-- Your code here; printed even when the field is empty -->
</header>
<?php endif ?>
```