Rate on Form Problem - Rating Element

marcelf

Member
Hi all,

I set in the administrator > edit element (rating) > Rate in form > YES

But when I go to add/edit record form and rate don't store my vote. Is this an error?

Thanks,
Marcel
 
It's working on my site.
What are your other settings?
Can you see any JS errors?
Which Joomla and Fabrik template?
 
Ah, OK.

The rating shouldn't even be available when creating a new form when "User rating" is enabled. That's because in user mode, the rating is stored in a separate table, #__fabrik_ratings, which we automatically create. That table has fields for form_id, row_id and user_id, so we can work out the average rating for each separate row and form, and restrict rating to one per user. And of course when a new form is being created, the row ID doesn't exist.

What it should do is display a notice ("Rating will be available once form is saved" or some such) instead of the stars. But for some reason, I commented that out ...

https://github.com/Fabrik/fabrik/blame/master/plugins/fabrik_element/rating/rating.php#L317

From the looks of the commit message for that change, I was working on allowing rating on new forms for "Creator rating". In that mode, we just store the rating directly in the form's own data, no need for the #__fabrik_ratings table, as each row only has a single rating.

I'll put that code back in, along with a test for the mode.

-- hugh
 
Ok, I understood, but there is another solution: is it possible after the creator give the rate and save the form, a javascript automatically click in the stars of recently created record and give the previous rate on the add form? In fact, I already have this habit. This could be a "dirty" solution, but it could work.
 
Not something I'd add to the code, but you could probably implement it with some custom JS.

I remember now what I was doing when I commented that code out, I was actually looking at some potential ways to allow user rating on a new form. But turned out that it's quite a lot of work, so I punted on doing it, I just forgot to uncomment that check for new record.

Basically, it would have to have a check on form load, and if new form and user rating enabled, disable the AJAX rating method, and instead add a onAfterProcess hook to retroactively add the #__fabrik_rating table entry from the submitted rating value, once we know the PK of the form.

But for now, the easiest way is just to rate it in the list, when you return to list view after submitting the form.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top