User:OliverCharles/ServerManual/Forms: Difference between revisions
(Starting work on #4756) |
(No difference)
|
Revision as of 11:29, 15 April 2009
Forms are created in 3 separate parts - designing the form at the data level, designing a view to the form, and adding controller logic to work with the form.
Writing Form Modules
Form modules are handled by writing Form::Processor modules, in the MusicBrainz::Server::Form namespace. You should add a new level of hierarchy to match the name of your controller (for example, MusicBrainz::Server::Form::Annotation::Edit).
Rather than inheriting directly from Form::Processor, it is best to inherit from MusicBrainz::Server::Form - this module exports some small helper methods to create common fields such as edit notes, and may do more in the future.
The single most important method in a form module is profile. This is the skeleton for a template, and will create all relevant fields. Your profile method should return a hash reference, with fields under the required and optional keys.
sub profile { return { required => { <name> => <type>, }, optional => { <name> => <type>, }, } }
Rather than documenting the details of how profile work here, you should read the official documentation.