You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.0 KiB
43 lines
1.0 KiB
<?php
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
/**
|
|
* Class ch_dropdown
|
|
*/
|
|
class ch_dropdown extends survey_question
|
|
{
|
|
/**
|
|
* @param array $survey_data
|
|
* @param $formData
|
|
* @return FormValidator
|
|
*/
|
|
public function createForm($survey_data, $formData)
|
|
{
|
|
parent::createForm($survey_data, $formData);
|
|
|
|
if (is_array($formData['answers'])) {
|
|
foreach ($formData['answers'] as $key => $value) {
|
|
$this->getForm()->addText('answers['.$key.']', $key + 1);
|
|
}
|
|
}
|
|
|
|
parent :: addRemoveButtons($formData);
|
|
}
|
|
|
|
/**
|
|
* @param FormValidator $form
|
|
* @param array $questionData
|
|
* @param array $answers
|
|
*/
|
|
public function render(FormValidator $form, $questionData = array(), $answers = '')
|
|
{
|
|
$name = 'question' . $questionData['question_id'];
|
|
$form->addSelect($name, null, $questionData['options']);
|
|
|
|
if (!empty($answers)) {
|
|
$form->setDefaults([$name => $answers]);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|