-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
displayValue initialization and value after update #6
Comments
Fixed with upgrade to new release 2.0. A new property |
Now after initializing widget with |
I think you still have a javascript caching problem - its referring old cached javascript or your extension is not updated properly - as mentioned in the other issue. You can check the demo page for the star rating refresh based on |
Cleared the cache, but that doesn't solve the problem. Also tried to change |
I am not sure I understand where you have the problem. Recheck your widget settings. On the demo page for example here is the setting for displayed value to automatically change via StarRating widget. On update - the rating returns a number 1 to 5 .. but the displayed value is auto calculated from echo Editable::widget([
'model'=>$model,
'attribute' => 'rating',
'type'=>'success',
'size'=>'lg',
'displayValueConfig'=>[
1=>'One Star',
2=>'Two Stars',
3=>'Three Stars',
4=>'Four Stars',
5=>'Five Stars',
],
'inputType'=>Editable::INPUT_RATING,
'editableValueOptions'=>['class'=>'text-success h2']
]); |
Let's say we have boolean value to edit (or integer values tied up with constants). Values in database are 0 for false and 1 for true.
To display user friendly values I wrote simple method which returns string 'yes' or 'no' according to attribute value. But when the value gets updated after ajax request, the new value becomes 0 or 1. That means it was directly taken from the JSON output and we must convert it to string by ourselves during JSON return.
I think it wiil be more flexible if we can just pass array like that [0 => 'No', 1 => 'Yes'] without creating dedicated method in model. For more complex arrays we can still use the method in model to retrieve array (or closure maybe). And if that array was set the value from the server after update will be automatically converted to proper string.
Or maybe it will be even better to have the separate options for array and single value and only one of them must be set.
The text was updated successfully, but these errors were encountered: