Commit fc117913 authored by Eric Windham's avatar Eric Windham Committed by Kenny Hall

Fixes Star Rating issues - Issue#2815 (#3370)

* made some changes to the star rating fields

* fixes default value and required setting for star rating field
parent 8f838e45
......@@ -12,15 +12,22 @@ define([], function() {
initRating: function( view ){
jQuery( view.el ).find( '.starrating' ).rating();
},
renderRatings: function() {
var html = document.createElement( 'span' );
for (var i = 0; i <= this.default - 1; i++) {
// changed from 'default' to 'number_of_stars'
for (var i = 0; i <= this.number_of_stars - 1; i++) {
var template = nfRadio.channel( 'app' ).request( 'get:template', '#tmpl-nf-field-starrating-star' );
var num = i + 1;
var htmlFragment = template( { id: this.id, classes: this.classes, num: num } );
var checked = '';
// Check to see if current 'star' matches the default value
if ( this.value == num ) {
checked = 'checked';
}
var htmlFragment = template( { id: this.id, classes: this.classes, num: num, checked: checked } );
html.appendChild(
document.createRange().createContextualFragment( htmlFragment )
);
......
File mode changed from 100755 to 100644
File mode changed from 100644 to 100755
File mode changed from 100755 to 100644
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -17,21 +17,15 @@ class NF_Fields_StarRating extends NF_Abstracts_Input
protected $_templates = 'starrating';
protected $_settings_only = array( 'label', 'label_pos', 'default', 'required', 'classes', 'key', 'admin_label' );
protected $_settings_only = array( 'label', 'label_pos', 'default',
'number_of_stars', 'required', 'classes', 'key', 'admin_label' );
public function __construct()
{
parent::__construct();
$this->_settings[ 'default' ][ 'group' ] = 'primary';
$this->_settings[ 'default' ][ 'label' ] = __( 'Number of Stars', 'ninja-forms' );
$this->_settings[ 'default' ][ 'width' ] = 'one-half';
$this->_settings[ 'default' ][ 'use_merge_tags' ] = FALSE;
$this->_settings[ 'default' ][ 'value' ] = 5;
// Put this in the primary settings group
$this->_settings['number_of_stars']['group'] = 'primary';
$this->_nicename = __( 'Star Rating', 'ninja-forms' );
}
......
......@@ -5,5 +5,7 @@
</script>
<script id="tmpl-nf-field-starrating-star" type="text/template">
<input type="radio" name="nf-field-{{{ data.id }}}" class="{{{ data.classes }}} nf-element" value="{{{ data.num }}}" />
<input type="radio" name="nf-field-{{{ data.id }}}"
class="{{{ data.classes }}} nf-element" value="{{{ data.num }}}"
{{{ data.checked }}}/>
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment