Savant2+Formation
The Why
Savant2 is my PHP template engine of choice because I don't believe that designers are too dumb to learn a programming language. If you don't trust people you're working with to be able to learn a language, why are you expecting them to learn the syntax of say Smarty (which is even more nonstandard than PHP...)
Savant does not however, have many plugins, and life is just hard if you reinvent the wheel every time you write a form. So I made a form plugin modeled after Formation, but with a Savant plug in handling output. Not content to simply steal an API, I also piggy backed off of the existing Savant form plugin to generate HTML, in the hopes upstream improvements would trickle down.
The How
Forms are constructed as a new class, with a constructor that defines all of the form elements:
-
class SignupForm extends form2_Form {
-
var $calendar;
-
var $pin = null;
-
-
function SignupForm(&$calendar, $days, $times, $day, $time) {
-
-
$this->calendar = $calendar;
-
-
//Name field
-
$i = &new form2_Text('join_name', 'Name');
-
// add a validator
-
// addValidator(function to call, message if failed)
-
$this->addElement($i);
-
-
// Timeslot field
-
foreach ($days as $j) {
-
}
-
$i = &new form2_Select('join_date', 'Timeslot', $h, $day);
-
$this->addElement($i);
-
-
// Submit button
-
$i = &new form2_Submit('submit', '', 'Sign Up!');
-
$this->addElement($i);
-
-
$this->form2_Form();
-
}
-
}
Then, to process the form, you well... err. Override the process method...
-
class SignupForm extends form2_Form {
-
//... constructor...
-
-
function process($values) {
-
// you can access form fields like this...
-
$join_name = $values['join_name'];
-
-
// ... put form processing code here
-
}
-
}
The Where
So check out the download (zip). Totally unsupported, I'd honestly be surprised if anyone got it working (or cared). But if you run into troubles, contact me, and I'll do what I can to *cough* actually document it.
PS: if you're curious, you can check out the source just to see what it is you're getting into. (Undocumented territory ahoy!)