the value of a CStarRating with specified model and attribute doesn't appear inside POST['modelname'] but in a separate part of the post array as POST['modelname_attributename'].
Why? can this widget be trated as standard activeHelpers?
the value of a CStarRating with specified model and attribute doesn't appear inside POST['modelname'] but in a separate part of the post array as POST['modelname_attributename'].
Why? can this widget be trated as standard activeHelpers?
How did you use it?
<?php echo $this->widget('CStarRating', array('model'=>$welding_tasks, 'attribute'=>'wdk_rating')); ?>
inside a _form.php file (part of the view files create and update).
this is the _POST array
Array ( [ped_welding_tasks] => Array ( [wdk_wpq] => [wdk_date] => 2009-02-23 ) [ped_welding_tasks_wdk_rating_] => 6 [yt0] => modifica )
as you can see the ped_welding_tasks_wdk_rating_ is out of the ped_welding_tasks key and is out of standard: modelname_attributename_ (it as also an underscore at the end of the attribute name)
What is $welding_tasks? Is it an array or an object?
it is an object. An instance of a model that extends CActiveRecord.
What is the generated HTML source code?
<div class="simple"> <label for="ped_welding_tasks_wdk_date" class="required">data <span class="required">*</span></label><input id="ped_welding_tasks_wdk_date" size="10" maxlength="10" name="ped_welding_tasks[wdk_date]" type="text" value=""/></div> <div class="simplestar"> <label for="ped_welding_tasks_wdk_rating">valutazione</label><span id="ped_welding_tasks_wdk_rating"> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_0" value="1" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_1" value="2" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_2" value="3" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_3" value="4" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_4" value="5" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_5" value="6" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_6" value="7" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_7" value="8" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_8" value="9" type="radio" name="ped_welding_tasks[wdk_rating]"/> <input class="{split:2}" id="ped_welding_tasks_wdk_rating_9" value="10" type="radio" name="ped_welding_tasks[wdk_rating]"/> </span></div>
this is the html code of the div containing a standard input text and the div containing the widget
The HTML code looks good to me. Is there any input field whose name is "ped_welding_tasks_wdk_rating_" ?
FYI, the extension page uses the star rating in a similar approach as yours.
the $_POST array should be (according to the form and the model):
Array ( [ped_welding_tasks] => Array ( [wdk_wpq] => [wdk_date] => 2009-02-23 [wdk_rating] => 6) [yt0] => modifica )
instead of
Array ( [ped_welding_tasks] => Array ( [wdk_wpq] => [wdk_date] => 2009-02-23 ) [ped_welding_tasks_wdk_rating_] => 6 [yt0] => modifica )
why is it structured in this way?
This is actually a bug of jquery.rating.js
In old version, I fixed it, but forgot to apply the fix to the new version (in SVN).
It's fixed now (in 1.0 branch).