Generates a `<select />` list using the `$list` parameter for the `<option />` tags. The default selection will be set to the value of `$options['value']`, if specified.
For example: {{{ $this->form->select('colors', array(1 => 'red', 2 => 'green', 3 => 'blue'), array( 'id' => 'Colors', 'value' => 2 )); // Renders a '<select />' list with options 'red', 'green' and 'blue', with the 'green' // option as the selection }}}

Parameters

  • string $name The `name` attribute of the `<select />` element.
  • array $list An associative array of key/value pairs, which will be used to render the list of options.
  • array $options Any HTML attributes that should be associated with the `<select />` element. If the `'value'` key is set, this will be the value of the option that is selected by default.

Returns

string Returns an HTML `<select />` element.

Source

						public function select($name, $list = array(), array $options = array()) {
		$defaults = array('empty' => false, 'value' => null);
		list($name, $options, $template) = $this->_defaults(__FUNCTION__, $name, $options);
		list($scope, $options) = $this->_options($defaults, $options);

		if ($scope['empty']) {
			$list = array('' => ($scope['empty'] === true) ? '' : $scope['empty']) + $list;
		}
		if ($template == __FUNCTION__ && $scope['multiple']) {
			$template = 'select-multi';
		}
		$raw = $this->_selectOptions($list, $scope);
		return $this->_render(__METHOD__, $template, compact('name', 'options', 'raw'));
	}