Skip to content

Instantly share code, notes, and snippets.

@nsams
Last active August 29, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsams/d6737f2f12508ad7e00f to your computer and use it in GitHub Desktop.
Save nsams/d6737f2f12508ad7e00f to your computer and use it in GitHub Desktop.
Static Contact Form
<?php
class Contact_Component extends Kwc_Form_Component
{
}
<?php
class Contact_FrontendForm extends Kwf_Form
{
protected function _init()
{
$this->setModel(new Kwf_Model_Mail(array('tpl' => 'mails/Contact')));
$columns = $this->add(new Kwf_Form_Container_Columns());
$col = $columns->add(new Kwf_Form_Container_Column());
$col->add(new Kwf_Form_Field_TextField('name', trlStatic('Vorname und Nachname')))
->setWidth(320)
->setAllowBlank(false);
$col->add(new Kwf_Form_Field_TextField('phone', trlStatic('Telefonnummer')))
->setAllowBlank(true)
->setWidth(320);
$col->add(new Kwf_Form_Field_TextField('email', trlStatic('E-Mail')))
->setWidth(320)
->setVtype('email')
->setAllowBlank(false);
$col = $columns->add(new Kwf_Form_Container_Column());
$col->add(new Kwf_Form_Field_TextArea('message', trlStatic('Ihre Nachricht an uns')))
->setWidth(640);
$col = $columns->add(new Kwf_Form_Container_Column());
$col->setCls('lastColumn');
$col->add(new Kwf_Form_Field_Static(''));
parent::_init();
}
protected function _beforeSave(Kwf_Model_Row_Interface $row)
{
$row->addTo('mail@example.com');
$row->subject = trl('Anfrage auf example.com',$host);
}
}
<?=trl('Sie erhielten eine Anfrage auf {0}', $this->host);?>.
<?=trl('Nachricht');?>:
<?= $this->message; ?>
<?=trl('Diese Anfrage wurde gesendet von');?>:
<?=trl('Name');?>: <?= $this->name; ?>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment