Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by jape ( 13 years ago )
public static $many_many = array(
'NabestelBladen' => 'NabestelBlad'
);
-----------------
function NabestellenForm() {
$nabestellijst= DataObject::get('NabestelBlad');
// Create fields
$fields = new FieldList (
new HeaderField('Vul het formulier hieronder om een nabestelling te plaatsen', 'Vul het formulier hieronder om een nabestelling te plaatsen', '1'),
new TextField('Naam', 'Naam*'),
new TextField('Tussenvoegsel', 'Tussenvoegsel'),
new TextField('Achternaam', 'Achternaam*'),
new TextField('Straat', 'Straat*'),
new TextField('Huisnummer', 'Huisnummer*'),
new TextField('Postcode', 'Postcode*'),
new TextField('Plaats', 'Plaats*'),
new TextField('Land', 'Land*'),
new TextField('Email', 'E-mail*'),
new NumericField('Telefoon','Telefoon'),
new CheckboxSetField('NabestelBlad', 'Kies een uitgave', $source = $nabestellijst ),
new DropdownField('Betalingsmogelijkheid', 'Betalingsmogelijkheid', array('Overschrijven' => 'Overschrijven' ))
);
// Create action
$acti FieldList (
new FormAction('SendNabestellenForm', 'Bestellen')
);
// Create Validators
$validator = new RequiredFields('Naam', 'Telefoon', 'Achternaam', 'Straat', 'Huisnummer', 'Postcode', 'Plaats', 'Land', 'Email' );
return new Form($this, 'NabestellenForm', $fields, $actions, $validator);
}
function SendNabestellenForm($data, $form) {
//Set data
$From = "[email protected]";
//$To = "[email protected]";
$To = "[email protected]";
$Subject = "Nabestelling NL";
$email = new Email($From, $To, $Subject);
//set template
$email->setTemplate('nabestellen');
// Implode checkbox values
if(isset($data['NabestelBlad'])) {$NabestelBlad= implode(',', $data['NabestelBlad']);} else {$NabestelBlad=' ';}
//populate template
$email->populateTemplate($data);
$email->populateTemplate(array('NabestelBlad'=> $NabestelBlad));
//send mail
$email->send();
//return to submitted message
Director::redirect($this->Link("?success=1"));
}
public function Success()
{
return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
}
Revise this Paste