Recent Topics

Radio buttons in plugins

Started by on Sep 10, 2008 – Contents updated: Sep 10, 2008

Sep 10, 2008 19:52    

I don't recall anyone mentioning this and I can't seem to find either an example or a setting that says it'll do it, so I would like to be able to make a radio button 'type' for a plugin setting. I can do a select, which effectively covers what a radio button would do (pick one of many), but still...

I'm working on overhauling the videoplug plugin. Part of what I would like to do is offer the options that the various video sources offer. YouTube for example offers color schemes for the base and optional border. At youtube you select an image that shows the colors, and selecting one will de-select any previous selection. In this case a radio button next to each image would simulate the effect without having to dumb it down to descriptions of the colors as I will have to do to use a select.

Sep 10, 2008 20:56

Hi EdB,

I think there is some technical problem with radio buttons. Can't think of any other reason for this omission.
Nevertheless you can really do anything with checkboxes but you may need to set a defaultvalue again since the user can disable them all. I mean not only setting a defaultvalue, but doing so again at the point where you *get()* this value because it may be empty / NULL if the user unchecked everything. The user couldn't have done so with *real* radiobuttons.

Good luck

Sep 11, 2008 10:12

See if this is off any use ;)

inc/plugins/model/_plugins_admin.class.php approx 75 wrote:

* - PluginSettingsEditDisplayAfter (Called after standard plugin settings are displayed for editing)
* - PluginSettingsValidateSet (Called before setting a plugin's setting in the backoffice)

function PluginSettingsEditDisplayAfter( $params )
{
	$current_value = 'bar'; // you'd set this dynamically ;)
	$params['Form']->radio( 'foo_input', $current_value, array(
					array( 'foo', 'foo_label' ),
					array( 'bar', 'bar_label' ),
			 ),'my radio label' );
}

¥

Sep 11, 2008 10:23

Wow thanks. I should give it a go but I already did my thing with a select box and text.

I should hurry up and put out videoplug_plugin 2.9.2.0 (or will it be 2.9.2.1?) before y'all come up with b2evo v3.whatever ...


Form is loading...

Advanced CMS – This forum is powered by b2evolution CMS, a complete engine for your website.