Not sure about your exact needs, but I don't think you'll need 15 different types of form fields? Usually TextField is just fine, and you can use the RequiredFields validator for simple required fields.
As for your LicenseKey Field. The Field itself could access the form data and see if the name and key values match. Here's a very simple example (complete class listing):
<?php
class LicenseKeyField extends TextField
{
function validate($validator){
if(!empty ($this->value)){
// get the Username field from the form. Of course this would be nicer
// if it wasn't hardcoded...
$other = $this->getForm()->dataFieldByName('Username');
$val = $other->value;
// check the license key against a given pattern. Here we say that
// only a value matching <Username> <dash> and four digits is a valid key
if(!preg_match("/$val\-\d{4}/", $this->value)){
$validator->validationError(
$this->name,
"This is not a valid license key",
"validation",
false
);
return false;
}
}
return true;
}
}
So in your form you'll have a TextField "Username" and a LicenseKeyField. The LicenseKeyField would also include the Username field for it's validation. So if you have entered "Mauzer" in username, a valid License key would be "Mauzer-1234"
Here's a simple form setup for testing. If the form gets complicated, it's probably better to create a custom class for your form (eg. RegisterForm extends Form).
<?php
class FormPage extends Page
{
}
class FormPage_Controller extends Page_Controller
{
function RegisterForm() {
$fields = new FieldSet(
new TextField('Company'),
new TextField('Username'),
new LicenseKeyField('LicenseKey')
);
$actions = new FieldSet(
new FormAction('submit', 'Submit')
);
$validator = new RequiredFields('Company', 'Username', 'LicenseKey');
$form = new Form($this, 'RegisterForm', $fields, $actions, $validator);
return $form;
}
function submit($data, $form){
// do something with the data...
return array();
}
}