Note that there are some explanatory texts on larger screens.

plurals
  1. POYiiframework Range Slider input
    text
    copied!<p>I have a user settings page where users can change the settings of the application. The users can input a number between 0 and 10. See screenshot: <a href="http://oi43.tinypic.com/2uerazp.jpg" rel="nofollow">http://oi43.tinypic.com/2uerazp.jpg</a></p> <p>Now I would like to transform the input fields into a range slider using the CJuiSliderInput widget of the yiiframework: <a href="http://www.yiiframework.com/doc/api/1.1/CJuiSliderInput#maxAttribute-detail" rel="nofollow">http://www.yiiframework.com/doc/api/1.1/CJuiSliderInput#maxAttribute-detail</a></p> <p>I cannot seem to get the code working, this is the current code in view: </p> <pre><code>&lt;?php foreach($settings as $i=&gt;$value): ?&gt; &lt;?php $setting=UserSetting::model()-&gt;findByPk($value-&gt;setting_id); ?&gt; &lt;h4&gt;&lt;?php echo CHtml::encode($setting-&gt;label); ?&gt;&lt;/h3&gt; &lt;?php echo CHtml::activeTextField($value,"[$i]value"); ?&gt; &lt;?php endforeach; ?&gt; </code></pre> <p>I would like to replace the activeTextField with </p> <pre><code>$this-&gt;widget('zii.widgets.jui.CJuiSliderInput',array( 'model'=&gt;$model, 'attribute'=&gt;'[$i]value', 'maxAttribute'=&gt;'timeMax', // additional javascript options for the slider plugin 'options'=&gt;array( 'range'=&gt;true, 'min'=&gt;0, 'max'=&gt;10, ), )); </code></pre> <p>What values do I need to fill in to the widget to get it to work? Each textField input is from a different model btw. </p> <p>The controller looks something like this(don't know if you need it): </p> <pre><code>$settingsvalues = UserSettingValue::model()-&gt;findAll('client_id=:id', array( ':id' =&gt; $id, )); if(isset($_POST['UserSettingValue'])){ $valid = true; foreach($settingsvalues as $i=&gt;$value){ if(isset($_POST['UserSettingValue'][$i])) $value-&gt;attributes = $_POST['UserSettingValue'][$i]; $value-&gt;save(); $valid = $value-&gt;validate() &amp;&amp; $valid; } if($valid) $value-&gt;save(); } $this-&gt;render('settings',array( 'model' =&gt; $model, 'settings' =&gt; $settingsvalues, )); </code></pre> <p>Thanks a lot! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload