Form Options

The following form methods are available to set form attributes.

<?php
// 'post' is the default method
$form = new \Vespula\Form\Form();

// Set automatic line feeds
$form->autoLf();

// Set the method explicitly to one of post or get
$form = new \Vespula\Form\Form('get');

// Override the contructor's method attribute
$form->method('get|post');

// Set the form action
$form->action('/some/uri');

// Set the form name
$form->name('foo');

// Set the form id
$form->id('bar');

// Set the form enctype to multipart/form-data
$form->multipart();

// Set the form class
$form->class('foo-class');

// Finally, you can set any attribute via the attribute() method
$form->attribute('some-attrib', 'some-value');

// These call all be chained together in a fluent way, but remember,
// the begin() method must come last as it does not return the form object.
echo $form->id('my-id')->class('my-class')->action('my-action')->begin();

// Outputs
// <form method="get" id="my-id" class="my-class" action="my-action">

// And be sure the close the form tag after you add elements
echo $form->end();