1 VoteWidget
With this widget content manager can add a voting form on the page he just must to specify parameters of the widget. Here is a complete list of parameters:
- id – unique identifier of current vote;
- author_id – identifier of the content manager who created it;
- question – wording of the question;
- answers – available response options, should be formulated according to the following form:
'key1' => array(
array(
'order' => 1, //optional
'text' => 'Yes',
),
'key2' => array(
'order' => 2, //optional
'text' => 'No',
)
)
- multiply – whether to allow the user to choose more than one answer;
- dynamic – option works if the user is allowed to choose only one answer (multiply=false). Whether to apply choice when user clicks on answer(true) or shows “save” button for this;
- allowAnonymous – whether to allow unauthorized users to make vote;
- additionalFields – array of key-value pairs, that will be send with form;
- ajax – whether to use the ajax to sent voting form;
- inPercents – whether to show the result as a percentage;
- precision – number of digits after the decimal point after rounding to show as percentage;
- resultsUnvotedShow – whether to show voting results to user who did not take part in this voting;
- poolVotedShow – whether to show available answers to user who have already voted;
- firstResult – whether it need to show the result first, when user clicks a button to show the available answers (ned ‘ajax’ => true).
<?php
$this->widget('vote.widgets.VoteWidget', array(
'id' => 'survey about cats',
'author_id' => 1,
'question' => 'Do you have a cat?',
'answers' => array(
'q1' => array('text' => 'Yes', 'order' => 1),
'q2' => array('text' => 'No', 'order' => 2),
),
'multiply' => false,
'dynamic' => true,
'allowAnonymous' => true,
'additionalFields' => array(
'pageName' => 'Page '.rand(),
'userStatus' => 'Status '.rand()
),
'inPercents' => true,
'precision' => 2,
'resultsUnvotedShow' => true,
'poolVotedShow' => false,
'firstResult' => false
)
);
?>