$form = new Form('Registration Form'); $fields = new FieldList( new TextField('Username'), new EmailField('Email'), new PasswordField('Password'), new PasswordField('Confirm Password') ); $form->setFields($fields);
$form = new Form('Search Form'); $fields = new FieldList( new TextField('Search Keyword', 'Search keyword'), new DropdownField( 'Category', 'Category', array( 'All categories', 'Books', 'Electronics', 'Clothing' ) ) ); $form->setFields($fields);In this code snippet, we create a new search form and a list of fields. We then use FieldList add to add a TextField for the search keyword and a DropdownField for the category selection. It is often used in PHP packages and libraries that deal with form building and handling such as Formidable Forms.