Search by

hksagentur / kirby-webform

hksagentur

Easily create and manage webforms in Kirby

Package info

github.com/hksagentur/kirby-webform

Type:kirby-plugin

pkg:composer/hksagentur/kirby-webform

Statistics

Installs: 412

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

3.4.0 2026-11-04 15:10 UTC

README

Easily create and manage webforms in Kirby, heavily inspired by Filament Forms.

Requirements

Kirby CMS (>=3.10)
PHP (>= 8.2)

Installation

Composer

composer require hksagentur/kirby-webform

Download

Download the project archive and copy the files to the plugin directory of your kirby installation. By default this directory is located at /site/plugins.

Configuration

Add a configuration file for a new form in site/forms.

<?php // site/forms/contact.php

use Webform\Action\Email;
use Webform\Form\Components\Button;
use Webform\Form\Components\TextInput;
use Webform\Form\Components\Textarea;
use Webform\Form\Form;

return Form::create()->children([
  TextInput::create('name')
    ->required(),
  TextInput::create('email')
    ->required()
    ->email(),
  Textarea::create('message')
    ->required()
    ->maxLength(255)
    ->rows(8),
  Button::create('submit')
    ->action(fn (FormSubmission $submission) => Email::create('contact')
      ->subject('Contact Form')
      ->from('no-reply@example.com')
      ->to('info@example.org')
      ->execute($submission)
    ),
]);

FAQ

How can I customize the directory from which the form configuration is read? You can provide a custom directory via Kirby’s `roots` structure. Open the `index.php` and adjust the initialization of the kirby core:
<?php // index.php

require __DIR__ . '/kirby/bootstrap.php';

$kirby = new Kirby([
  'roots' => [
    'webforms' => dirname(__DIR__) . '/site/webforms',
  ],
]);

echo $kirby->render();
How can I customize the header and footer of the submission email? The HTML email renders the snippets `webform/emails/header` and `webform/emails/footer`. The header shows the site title by default, the footer the `footerLinks` and `footerLines` of the email data or a copyright line. Override either with a snippet of the same name in your site, e.g. to show a logo. Prefer PNG over SVG, since Outlook and Gmail don’t display SVG, and keep the `alt` text meaningful for clients that block images:
<?php // site/snippets/webform/emails/header.php ?>
<a href="<?= $site->url() ?>" target="_blank">
  <img src="<?= asset('assets/images/email-logo.png')->url() ?>" alt="<?= $site->title()->esc('attr') ?>" width="240" height="64" style="display:block;border:0;">
</a>

Both snippets receive $site, $kirby and the colours of the template as $theme ($theme->headingColor, $theme->accentColor, …); the footer also receives $footerLinks and $footerLines.

How can I change the colours of the submission email? Emails use the theme named in the option `hksagentur.webform.email.theme` (`light` by default) from the option `hksagentur.webform.email.themes`; colours you leave out keep their default:
// site/config/config.php
return [
    'hksagentur.webform.email.themes' => [
        'light' => [
            'accentColor' => '#c00000',
        ],
    ],
];

The colours are textColor, accentColor and backgroundColor, plus surfaceColor (defaults to backgroundColor), headingColor and footerColor (both default to textColor). Add further themes next to light, make one the default with 'hksagentur.webform.email.theme' => 'campaign', or choose one per email with theme in the data of its preset, e.g. 'data' => ['theme' => 'campaign'], or with ->theme('campaign') on its Email action. Both also take an array of colours that replace single colours, e.g. ->theme(['accentColor' => '#00aa00']). The name dark is reserved for a future dark mode.

License

ISC License. Please see License File for more information.