creating dropdown menu in ACP

User avatar

Topic author
talonos
Portal Specialist
Portal Specialist
Posts: 233
Joined: 7. June 2009 15:12
phpBB.com User: talonos

creating dropdown menu in ACP

Post by talonos » 27. May 2013 13:46

ok so i've created a few basic blocks upto now and i've started to work on one thats a bit more complex.

the problem i'm having is creating a custom dropdown menu in the acp that will store the selected value.

i'll show what i have already and maybe someone could point out where i've gone wrong.

get_template_side

Code: Select all

'DK_1'	=> ($config['board3_recruitmentdk1_' . $module_id]),
get_template_acp

Code: Select all

'board3_recruitmentdk1_' . $module_id			=> array('lang' => 'DK1',	'validate' => 'string', 	'type' => 'custom',	'explain' => true,	'method' => 'select_recruit', 'submit' => 'store_recruit'),
install

Code: Select all

set_config('board3_recruitmentdk1_' . $module_id, 'Medium');
custom php

Code: Select all

		public function select_recruit($value, $key, $module_id)
	{
		global $db, $cache;
		
		// Build options
		$ext_options = '<select id="' . $key . '" name="' . $key . '[]">';
		$ext_options .= '<option value="None">None</option><option value="Low">Low</option><option value="Medium">Medium</option><option value="High">High</option>';
		$ext_options .= '</select>';
		
		return $ext_options;
	}
	
	public function store_recruit($key, $module_id)
	{
		global $db, $cache;
		
		// Get selected extensions
		$values = request_var($key, array(0 => ''));
		$valuess = implode(',', $values);
		set_config($key, $valuess);

	}
}
within the ACP it seems to work fine apart from the selected values are not working and theres no error logs to say theres a problem.
Creating board3 website? check the sites out below for board3 compatible extensions
Talonos: Pretereo stormrage EU

User avatar

Topic author
talonos
Portal Specialist
Portal Specialist
Posts: 233
Joined: 7. June 2009 15:12
phpBB.com User: talonos

Re: creating dropdown menu in ACP

Post by talonos » 27. May 2013 14:35

ok seems i got it fixed. i've posted my finished code above for anyone else who might possibly find it of use. the thing i missed was the

Code: Select all

$valuess = implode(',', $values);
as soon as i added that i worked without fault.
Creating board3 website? check the sites out below for board3 compatible extensions
Talonos: Pretereo stormrage EU

Return to “Modifications Support”