Since ActionForms tend to be rather dull and unexciting to create, primarily because they are primitive information holders of string values that come out of the request, a code generator has been provided that does much of the legwork.
You can find this generator in the studs module of the framework:
studs/src/studs/resources/actionform_generator.php
If you have the starter package (studs-basic), it can be found at:
studs-basic/WEB-INF/lib/studs/resources/actionform_generator.php
There isn’t anything too fancy about running this tool. If you need to generate an action for for user logins called LoginForm that has three properties: username, password, and rememberMe, it can be done with the following shell command:
$> php actionform_generator.php LoginForm username password rememberMe
This command will produce a file named LoginForm.php in the same directory with the following contents:
<?php import('studs.action.ActionForm'); /* (non-Phpdoc) * Auto-generated by Studs action form generator. */ class LoginForm extends ActionForm { var $username; var $password; var $rememberMe; function setUsername($value) { $this->username = $value; } function getUsername() { return $this->username; } function setPassword($value) { $this->password = $value; } function getPassword() { return $this->password; } function setRememberMe($value) { $this->rememberMe = $value; } function getRememberMe() { return $this->rememberMe; } function &validate(&$mapping, &$request) { $errors =& parent::validate($mapping, $request); return $errors; } } ?>
If you want to inherit from a different base class each time, rather than the default studs.action.ActionForm, you may change the following setting at the top of the actionform_generator.php script:
$baseActionForm = 'studs.action.ActionForm';