common/components/FormDesigner.php
public function getRatingField( $config = [] ) {

		$class		= isset( $config[ 'class' ] ) && !empty( $config[ 'class' ] ) ? $config[ 'class' ] : 'cmt-rating';
		$stars		= isset( $config[ 'stars' ] ) ? $config[ 'stars' ] : 5;
		$label		= isset( $config[ 'label' ] ) ? $config[ 'label' ] : null;
		$readOnly	= isset( $config[ 'readOnly' ] ) ? $config[ 'readOnly' ] : false;
		$selected	= isset( $config[ 'selected' ] ) ? $config[ 'selected' ] : 0;
		$disabled	= isset( $config[ 'disabled' ] ) ? $config[ 'disabled' ] : false;

		// By default message provided for 5 stars
		$starMessage = isset( $config[ 'message' ] ) ? $config[ 'message' ] : [ "Poor", "Good", "Very Good", "Perfect", "Excellent" ];

		$modelName	= $config[ 'modelName' ];
		$fieldName	= isset( $config[ 'fieldName' ] ) ? $config[ 'fieldName' ] : 'rating';
		$fieldName	= $modelName . "[$fieldName]";

		if( $readOnly ) {

			$class = "$class read-only";
		}

		if( $disabled ) {

			$class = "$class disabled";
		}

		if( isset( $label ) ) {

			// element-60 will work if form is configured for 40-60 split, else it will behave as normal field
			$ratingHtml	= "<label>$label</label><div class=\"element-60 $class\">";
		}
		else {

			$ratingHtml	= "<div class=\"$class\">";
		}

		$ratingHtml .= '<span class="wrap-stars">';

		for( $i = 1; $i <= $stars; $i++ ) {

			if( $selected == $i ) {

				$icon = "<span star=\"$i\" class=\"star selected\"></span>";
			}
			else {

				$icon = "<span star=\"$i\" class=\"star\"></span>";
			}

			$ratingHtml .= $icon;
		}

		$ratingHtml .= '</span>';

		$ratingHtml .= '<span class="wrap-messages">';

		for( $i = 1; $i <= $stars; $i++ ) {

			$message = $starMessage[ $i - 1 ];

			if( $selected == $i ) {

				$icon = "<span star-message=\"$i\" class=\"star-message selected\">$message</span>";
			}
			else {

				$icon = "<span star-message=\"$i\" class=\"star-message\">$message</span>";
			}

			$ratingHtml .= $icon;
		}

		$ratingHtml .= '</span>';

		$ratingHtml	.= '<input class="star-selected" type="hidden" name="' . $fieldName . '" value="' . $selected . '">';

		$ratingHtml	.= "</div>";

		return $ratingHtml;
	}
public function getRatingField( $config = [] ) {

		$class		= isset( $config[ 'class' ] ) && !empty( $config[ 'class' ] ) ? $config[ 'class' ] : 'cmt-rating';
		$stars		= isset( $config[ 'stars' ] ) ? $config[ 'stars' ] : 5;
		$label		= isset( $config[ 'label' ] ) ? $config[ 'label' ] : null;
		$readOnly	= isset( $config[ 'readOnly' ] ) ? $config[ 'readOnly' ] : false;
		$selected	= isset( $config[ 'selected' ] ) ? $config[ 'selected' ] : 0;
		$disabled	= isset( $config[ 'disabled' ] ) ? $config[ 'disabled' ] : false;

		// By default message provided for 5 stars
		$starMessage = isset( $config[ 'message' ] ) ? $config[ 'message' ] : [ "Poor", "Good", "Very Good", "Perfect", "Excellent" ];

		$modelName	= $config[ 'modelName' ];
		$fieldName	= isset( $config[ 'fieldName' ] ) ? $config[ 'fieldName' ] : 'rating';
		$fieldName	= $modelName . "[$fieldName]";

		if( $readOnly ) {

			$class = "$class read-only";
		}

		if( $disabled ) {

			$class = "$class disabled";
		}

		if( isset( $label ) ) {

			// element-60 will work if form is configured for 40-60 split, else it will behave as normal field
			$ratingHtml	= "<label>$label</label><div class=\"element-60 $class\">";
		}
		else {

			$ratingHtml	= "<div class=\"$class\">";
		}

		$ratingHtml .= '<span class="wrap-stars">';

		for( $i = 1; $i <= $stars; $i++ ) {

			if( $selected == $i ) {

				$icon = "<span star=\"$i\" class=\"star selected\"></span>";
			}
			else {

				$icon = "<span star=\"$i\" class=\"star\"></span>";
			}

			$ratingHtml .= $icon;
		}

		$ratingHtml .= '</span>';

		$ratingHtml .= '<span class="wrap-messages">';

		for( $i = 1; $i <= $stars; $i++ ) {

			$message = $starMessage[ $i - 1 ];

			if( $selected == $i ) {

				$icon = "<span star-message=\"$i\" class=\"star-message selected\">$message</span>";
			}
			else {

				$icon = "<span star-message=\"$i\" class=\"star-message\">$message</span>";
			}

			$ratingHtml .= $icon;
		}

		$ratingHtml .= '</span>';

		$ratingHtml	.= '<input class="star-selected" type="hidden" name="' . $fieldName . '" value="' . $selected . '">';

		$ratingHtml	.= "</div>";

		return $ratingHtml;
	}
public function getRatingField ( $ config = [ ] ) { $ class = isset ( $ config [ 'class' ] ) && ! empty ( $ config [ 'class' ] ) ? $ config [ 'class' ] : 'cmt-rating' ; $ stars = isset ( $ config [ 'stars' ] ) ? $ config [ 'stars' ] : 5 ; $ label = isset ( $ config [ 'label' ] ) ? $ config [ 'label' ] : null ; $ readOnly = isset ( $ config [ 'readOnly' ] ) ? $ config [ 'readOnly' ] : false ; $ selected = isset ( $ config [ 'selected' ] ) ? $ config [ 'selected' ] : 0 ; $ disabled = isset ( $ config [ 'disabled' ] ) ? $ config [ 'disabled' ] : false ; // By default message provided for 5 stars $ starMessage = isset ( $ config [ 'message' ] ) ? $ config [ 'message' ] : [ "Poor" , "Good" , "Very Good" , "Perfect" , "Excellent" ] ; $ modelName = $ config [ 'modelName' ] ; $ fieldName = isset ( $ config [ 'fieldName' ] ) ? $ config [ 'fieldName' ] : 'rating' ; $ fieldName = $ modelName . "[$fieldName]" ; if ( $ readOnly ) { $ class = "$class read-only" ; } if ( $ disabled ) { $ class = "$class disabled" ; } if ( isset ( $ label ) ) { // element-60 will work if form is configured for 40-60 split, else it will behave as normal field $ ratingHtml = "<label>$label</label><div class=\"element-60 $class\">" ; } else { $ ratingHtml = "<div class=\"$class\">" ; } $ ratingHtml .= '<span class="wrap-stars">' ; for ( $ i = 1 ; $ i <= $ stars ; $ i ++ ) { if ( $ selected == $ i ) { $ icon = "<span star=\"$i\" class=\"star selected\"></span>" ; } else { $ icon = "<span star=\"$i\" class=\"star\"></span>" ; } $ ratingHtml .= $ icon ; } $ ratingHtml .= '</span>' ; $ ratingHtml .= '<span class="wrap-messages">' ; for ( $ i = 1 ; $ i <= $ stars ; $ i ++ ) { $ message = $ starMessage [ $ i - 1 ] ; if ( $ selected == $ i ) { $ icon = "<span star-message=\"$i\" class=\"star-message selected\">$message</span>" ; } else { $ icon = "<span star-message=\"$i\" class=\"star-message\">$message</span>" ; } $ ratingHtml .= $ icon ; } $ ratingHtml .= '</span>' ; $ ratingHtml .= '<input class="star-selected" type="hidden" name="' . $ fieldName . '" value="' . $ selected . '">' ; $ ratingHtml .= "</div>" ; return $ ratingHtml ; }
Generate and return stars html with hidden field.

@param type $config
@return string
Generate and return stars html with hidden field .