Example form is linked to a database table, but won't be saved in this example.

When you submit the form, the value is presented with debug_dump(), so strings are quoted and array values listed.

:
: - Stop the submitted form from bring processed
: - Don't process the form, redirect to another page (e.g. login after session timeout), and remember the values for when they return.

or back to examples


<?php
	$items = array(
		'A' => 'Item A',
		'B' => 'Item B',
		'C' => 'Item C',
		'D' => 'Item D',
		'E' => 'Item E',
	);
	$groups = array(
		'B' => 'Group 1',
		'C' => 'Group 1',
		'D' => 'Group 2',
		'E' => NULL,
	);
	$field = new form_field_select($form, 'Items');
	$field->db_field_set('items', 'key'); // Drop second parameter if you want to store the value
	$field->options_set($items); // Can be removed if using a database enum/set field
	$field->label_option_set('');
	$field->required_error_set('An item is required.');
	// $value = $this->value_get();
	// $value = $this->value_key_get();
?>