Is there any way to use a Fivestar widget other than the default one? I have a widget added via hook_fivestar_widgets() and I would like to use it in my webform rather than the default, but I do not see any option in the configuration to support changing the form widget.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shellshocked59’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

I was able to do this through code. I created a new module called "MYMODULE"

function MYMODULE_fivestar_widgets(){
		$widgets_directory = drupal_get_path('module', 'MYMODULE').'/widgets';
		$files = file_scan_directory($widgets_directory, '/\.css$/');
		$widgets = array();
		foreach($files as $file){
			if(strpos($file->filename, '-rtl.css') === false){
				$widgets[$file->uri] = drupal_ucfirst($file->name);
			}
		}
	
		return $widgets;
	}
	
	//Adds helper text to the fivestar
	function MYMODULE_form_alter(&$form, &$form_state, $form_id){
		if($form_id == 'webform_client_form_1'){
			$form['submitted']['rating']['#description'] = 'On a scale from 1 to 4, how would you rate this person?';
		}
	}

And also included a "widgets" folder in my custom module. This folder contained "MYMODULE.css", which used custom CSS that was ripped and altered from the existing "fivestar/widgets/basic/basic.css" with my own sprite in the same style of "fivestar/widgets/basic/star.png", just with my own images.

firstvoder’s picture

Hello shellshocked59,

Thx for posting your solution.

Does this allow for adding multiple, different rating icons that come with the fivestar widget (e.g. flames, oxygen etc) on the same form/questionnaire?

Basically, id like to have for each of the 8 questions/factors a different icon (flames icon for factor a, oxygen for factor b) showing up.

kind regards,

keesje’s picture

Status: Closed (works as designed) » Needs work

Thanx for posting your workaround, but this isn't a real fix for adding widget support IMHO. So, reopening this issue.

rooby’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
4 KB

Here's a patch that adds the ability to select from the different stars widgets.

It doesn't allow you to select between starts and a select field though, that would be a separate issue.