protected function Form_Create() { $this->Draggable = new QPanel($this); $this->Draggable->Text = 'Drag me'; $this->Draggable->CssClass = 'draggable'; $this->Draggable->Moveable = true; //$this->Draggable->AddAction(new QDraggable_StopEvent(), new QJavascriptAction("alert('Dragged to ' + ui.position.top + ',' + ui.position.left)")); $this->Draggable->AddAction(new QDraggable_StopEvent(), new QAjaxAction("drag_stop")); // Dropable $this->Droppable = new QPanel($this); $this->Droppable->Text = "Drop here"; //$this->Droppable->AddAction(new QDroppable_DropEvent(), new QJavascriptAction("alert('Dropped ' + ui.draggable.attr('id'))")); $this->Droppable->AddAction(new QDroppable_DropEvent(), new QAjaxAction("droppable_drop")); $this->Droppable->CssClass = 'droppable'; $this->Droppable->Droppable = true; // Resizable $this->Resizable = new QPanel($this); $this->Resizable->CssClass = 'resizable'; $this->Resizable->Resizable = true; $this->Resizable->AddAction(new QResizable_StopEvent(), new QAjaxAction('resizable_stop')); // Selectable $this->Selectable = new QSelectable($this); $this->Selectable->AutoRenderChildren = true; $this->Selectable->CssClass = 'selectable'; for ($i = 1; $i <= 5; ++$i) { $pnl = new QPanel($this->Selectable); $pnl->Text = 'Item ' . $i; $pnl->CssClass = 'selitem'; } $this->Selectable->Filter = 'div.selitem'; $this->Selectable->SelectedItems = array($pnl->ControlId); // pre-select last item $this->Selectable->AddAction(new QSelectable_StopEvent(), new QAjaxAction('selectable_stop')); // Sortable $this->Sortable = new QSortable($this); $this->Sortable->AutoRenderChildren = true; $this->Sortable->CssClass = 'sortable'; for ($i = 1; $i <= 5; ++$i) { $pnl = new QPanel($this->Sortable); $pnl->Text = 'Item ' . $i; $pnl->CssClass = 'sortitem'; } $this->Sortable->Items = 'div.sortitem'; $this->Sortable->AddAction(new QSortable_StopEvent(), new QAjaxAction('sortable_stop')); // Accordion $this->Accordion = new QAccordion($this); $lbl = new QLinkButton($this->Accordion); $lbl->Text = 'Header 1'; $pnl = new QPanel($this->Accordion); $pnl->Text = 'Section 1'; $lbl = new QLinkButton($this->Accordion); $lbl->Text = 'Header 2'; $pnl = new QPanel($this->Accordion); $pnl->Text = 'Section 2'; $lbl = new QLinkButton($this->Accordion); $lbl->Text = 'Header 3'; $pnl = new QPanel($this->Accordion); $pnl->Text = 'Section 3'; $this->Accordion->AddAction(new QChangeEvent(), new QAjaxAction('accordion_change')); // Autocomplete // Both autocomplete controls below will use the mode // "match only on the beginning of the word" QAutocomplete::UseFilter(QAutocomplete::FILTER_STARTS_WITH); // Client-side only autocomplete $this->Autocomplete1 = new QAutocomplete($this); $this->Autocomplete1->Source = self::$LANGUAGES; $this->Autocomplete1->Name = "Standard Autocomplete"; $this->Autocomplete2 = new QAutocomplete($this); $this->Autocomplete2->Source = self::$LANGUAGES; $this->Autocomplete2->AutoFocus = true; $this->Autocomplete2->MustMatch = true; $this->Autocomplete2->Name = "AutoFocus and MustMatch"; // Ajax Autocomplete // Note: To show the little spinner while the ajax search is happening, you // need to define the .ui-autocomplete-loading class in a style sheet. See // header.inc.php for an example. $this->AjaxAutocomplete = new QAutocomplete($this); $this->AjaxAutocomplete->SetDataBinder("update_autocompleteList"); $this->AjaxAutocomplete->AddAction(new QAutocomplete_ChangeEvent(), new QAjaxAction('ajaxautocomplete_change')); $this->AjaxAutocomplete->DisplayHtml = true; $this->AjaxAutocomplete->Name = 'With Html Display'; $this->AjaxAutocomplete2 = new QAutocomplete($this); $this->AjaxAutocomplete2->MultipleValueDelimiter = ','; $this->AjaxAutocomplete2->SetDataBinder("update_autocompleteList"); $this->AjaxAutocomplete2->Name = 'Multiple selection'; // Button $this->Button = new QJqButton($this); $this->Button->Label = "Click me"; // Label overrides Text $this->Button->AddAction(new QClickEvent(), new QServerAction("button_click")); $this->CheckBox = new QJqCheckBox($this); $this->CheckBox->Text = "CheckBox"; $this->RadioButton = new QJqRadioButton($this); $this->RadioButton->Text = "RadioButton"; $this->IconButton = new QJqButton($this); $this->IconButton->Text = "Sample"; $this->IconButton->ShowText = false; $this->IconButton->Icons = array("primary" => JqIcon::Lightbulb); // Lists $this->CheckList1 = new QCheckBoxList($this); $this->CheckList1->Name = "CheckBoxList with buttonset"; foreach (self::$LANGUAGES as $strLang) { $this->CheckList1->AddItem($strLang); } $this->CheckList1->ButtonMode = QCheckBoxList::ButtonModeSet; $this->CheckList2 = new QCheckBoxList($this); $this->CheckList2->Name = "CheckBoxList with button style"; foreach (self::$LANGUAGES as $strLang) { $this->CheckList2->AddItem($strLang); } $this->CheckList2->ButtonMode = QCheckBoxList::ButtonModeJq; $this->CheckList2->RepeatColumns = 4; $this->RadioList1 = new QRadioButtonList($this); $this->RadioList1->Name = "RadioButtonList with buttonset"; foreach (self::$LANGUAGES as $strLang) { $this->RadioList1->AddItem($strLang); } $this->RadioList1->ButtonMode = QCheckBoxList::ButtonModeSet; $this->RadioList2 = new QRadioButtonList($this); $this->RadioList2->Name = "RadioButtonList with button style"; foreach (self::$LANGUAGES as $strLang) { $this->RadioList2->AddItem($strLang); } $this->RadioList2->ButtonMode = QCheckBoxList::ButtonModeJq; $this->RadioList2->RepeatColumns = 4; // Datepicker $this->Datepicker = new QDatepicker($this); // DatepickerBox $this->DatepickerBox = new QDatepickerBox($this); // Dialog $this->Dialog = new QDialog($this); $this->Dialog->Text = 'a non modal dialog'; $this->Dialog->AddButton('Cancel', 'cancel'); $this->Dialog->AddButton('OK', 'ok'); $this->Dialog->AddAction(new QDialog_ButtonEvent(), new QAjaxAction('dialog_press')); $this->Dialog->AutoOpen = false; $this->btnShowDialog = new QJqButton($this); $this->btnShowDialog->Text = 'Show Dialog'; $this->btnShowDialog->AddAction(new QClickEvent(), new QShowDialog($this->Dialog)); $this->txtDlgTitle = new QTextBox($this); $this->txtDlgTitle->Name = "Set Title To:"; $this->txtDlgTitle->AddAction(new QKeyPressEvent(10), new QAjaxAction('dlgTitle_Change')); $this->txtDlgTitle->AddAction(new QBackspaceKeyEvent(10), new QAjaxAction('dlgTitle_Change')); $this->txtDlgText = new QTextBox($this); $this->txtDlgText->Name = "Set Text To:"; $this->txtDlgText->AddAction(new QKeyPressEvent(10), new QAjaxAction('dlgText_Change')); $this->txtDlgText->AddAction(new QBackspaceKeyEvent(10), new QAjaxAction('dlgText_Change')); // Progressbar $this->Progressbar = new QProgressbar($this); $this->Progressbar->Value = 37; // Slider $this->Slider = new QSlider($this); $this->Slider->AddAction(new QSlider_SlideEvent(), new QJavascriptAction('jQuery("#' . $this->Progressbar->ControlId . '").progressbar ("value", ui.value)')); $this->Slider->AddAction(new QSlider_ChangeEvent(), new QAjaxAction('slider_change')); $this->Slider2 = new QSlider($this); $this->Slider2->Range = true; $this->Slider2->Values = array(10, 50); $this->Slider2->AddAction(new QSlider_ChangeEvent(), new QAjaxAction('slider2_change')); // Tabs $this->Tabs = new QTabs($this); $tab1 = new QPanel($this->Tabs); $tab1->Text = 'First tab is active by default'; $tab2 = new QPanel($this->Tabs); $tab2->Text = 'Tab 2'; $tab3 = new QPanel($this->Tabs); $tab3->Text = 'Tab 3'; $this->Tabs->Headers = array('One', 'Two', 'Three'); }
/** * Creates all the controls for each "question" in the form. * Note: For any fields that are looked up from the user's profile (e.g. address, phone, etc.) -- a drop down is available for quick access. * However, if they select "other", we save the data and do NOT link it to any records! * (e.g. if an "other" phone is used, that data is not stored anywhere else) */ protected function CreateFormItemControls() { /** * @var Person */ $objPerson = $this->objSignupEntry->Person; if ($objPerson != null) { // First, set up for the Person Name label $lblPersonName = new QLabel($this, 'lblPersonName'); $lblPersonName->Name = 'Name'; $lblPersonName->Required = true; $lblPersonName->Text = $objPerson->Name; $lblPersonName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lblPersonName; } else { // else if not logged in, prompt for First and Last Name. Always. $txtFirstName = new QTextBox($this); $txtFirstName->Name = 'First Name'; $txtFirstName->Required = true; $txtFirstName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtFirstName; $txtLastName = new QTextBox($this); $txtLastName->Name = 'Last Name'; $txtLastName->Required = true; $txtLastName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtLastName; } // Go through all the other fields foreach ($this->objSignupForm->GetFormQuestionArray(QQ::OrderBy(QQN::FormQuestion()->OrderNumber)) as $objFormQuestion) { // Only display if this is NOT "InternalFlag" if ($objFormQuestion->InternalFlag) { continue; } $strControlId = 'fq' . $objFormQuestion->Id; $objFormAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($this->objSignupEntry->Id, $objFormQuestion->Id); switch ($objFormQuestion->FormQuestionTypeId) { case FormQuestionType::SpouseName: if ($objPerson != null) { if (($objMarriage = $objPerson->GetMostRecentMarriage()) && $objMarriage->MarriedToPerson) { $lstSpouse = new QListBox($this, $strControlId . 'id'); $lstSpouse->ActionParameter = $strControlId . 'nm'; if (!$objFormQuestion->RequiredFlag) { $lstSpouse->AddItem('- Select One -', null); } $lstSpouse->AddItem($objMarriage->MarriedToPerson->Name, $objMarriage->MarriedToPerson->Id, true); $lstSpouse->AddItem('- Other... -', false); $lstSpouse->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); $lstSpouse->Name = $objFormQuestion->Question; if ($objFormQuestion->RequiredFlag) { $lstSpouse->Required = true; } $lstSpouse->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstSpouse; $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = false; $txtName->Required = false; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { if ($lstSpouse->SelectedName != $objFormAnswer->TextValue) { $lstSpouse->SelectedIndex = count($lstSpouse->GetAllItems()) - 1; $txtName->Text = $objFormAnswer->TextValue; $this->lst_ToggleOther(null, $lstSpouse->ControlId, $lstSpouse->ActionParameter); } } } else { $lstSpouse = new QListBox($this, $strControlId . 'id'); $lstSpouse->Visible = false; if ($objFormQuestion->RequiredFlag) { $lstSpouse->Required = true; } $lstSpouse->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstSpouse; $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->Name = $objFormQuestion->Question; $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = true; $txtName->Required = $objFormQuestion->RequiredFlag; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { $txtName->Text = $objFormAnswer->TextValue; } } } else { $txtName = new QTextBox($this, $strControlId . 'nm'); $txtName->Name = $objFormQuestion->Question; $txtName->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtName; $txtName->Visible = true; $txtName->Required = $objFormQuestion->RequiredFlag; if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { $txtName->Text = $objFormAnswer->TextValue; } } break; case FormQuestionType::Address: if ($objPerson != null) { $objHouseholdArray = Household::LoadArrayBySharedHouseholds($objPerson, $this->objSignupEntry->SignupByPerson); if (count($objHouseholdArray) > 1) { // TODO: Implement! throw new Exception('TODO: Not Implemented'); } else { if (count($objHouseholdArray) == 1) { $objAddress = $objHouseholdArray[0]->GetCurrentAddress(); $rblAddress = new QRadioButtonList($this, $strControlId . 'switch'); $rblAddress->Name = $objFormQuestion->Question; $rblAddress->RenderMethod = 'RenderWithName'; $rblAddress->AddItem('Use Home Address Below', $objAddress->Id, true); $rblAddress->AddItem('Edit Home Address', false, false); $rblAddress->RepeatColumns = 2; $rblAddress->AddAction(new QClickEvent(), new QAjaxAction('rblAddress_Change')); $this->objFormQuestionControlArray[] = $rblAddress; } else { $objAddress = new Address(); $rblAddress = null; } } } $txtAddress1 = new QTextBox($this, $strControlId . 'address1'); $txtAddress1->Name = 'Address 1'; $txtAddress1->RenderMethod = 'RenderWithName'; $txtAddress1->Text = $objPerson != null ? $objAddress->Address1 : ''; $txtAddress2 = new QTextBox($this, $strControlId . 'address2'); $txtAddress2->Name = 'Address 2'; $txtAddress2->RenderMethod = 'RenderWithName'; $txtAddress2->Text = $objPerson != null ? $objAddress->Address2 : ''; $txtCity = new QTextBox($this, $strControlId . 'city'); $txtCity->Name = 'City, State and Zip'; $txtCity->RenderMethod = 'RenderWithName'; $txtCity->Text = $objPerson != null ? $objAddress->City : ''; $lstState = new QListBox($this, $strControlId . 'state'); $lstState->ActionParameter = '_' . $strControlId . 'city'; $lstState->Name = QApplication::Translate('State'); $lstState->RenderMethod = 'RenderWithError'; $lstState->AddItem(QApplication::Translate('- Select One -'), null); foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) { if ($objPerson != null) { $lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $objAddress->State == $objUsState->Abbreviation); } else { $lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, false); } } $txtZipCode = new QTextBox($this, $strControlId . 'zipcode'); $txtZipCode->ActionParameter = '_' . $strControlId . 'city'; $txtZipCode->Name = 'Zip Code'; $txtZipCode->RenderMethod = 'RenderWithError'; $txtZipCode->Text = $objPerson != null ? $objAddress->ZipCode : ''; $txtZipCode->Width = '80px'; if ($objFormQuestion->RequiredFlag) { $txtAddress1->Required = true; $txtCity->Required = true; $lstState->Required = true; $txtZipCode->Required = true; } $this->objFormQuestionControlArray[] = $txtAddress1; $this->objFormQuestionControlArray[] = $txtAddress2; $this->objFormQuestionControlArray[] = $txtCity; $this->objFormQuestionControlArray[] = $lstState; $this->objFormQuestionControlArray[] = $txtZipCode; // Final configuration based on whether or not we've got a household record for this person // (in which case we have defined a rblAddress) if ($objPerson != null) { if ($rblAddress) { // Check to see if the question has been answered before if ($objFormAnswer && strlen($objFormAnswer->TextValue)) { // If it $objAddress = Address::DeduceAddressFromFullLine($objFormAnswer->TextValue); if ($objFormAnswer->AddressId == $rblAddress->SelectedValue || !$objAddress) { $txtAddress1->Enabled = false; $txtAddress2->Enabled = false; $txtCity->Enabled = false; $lstState->Enabled = false; $txtZipCode->Enabled = false; } else { $txtAddress1->Text = $objAddress->Address1; $txtAddress2->Text = $objAddress->Address2; $txtCity->Text = $objAddress->City; $txtZipCode->Text = $objAddress->ZipCode; $lstState->SelectedValue = $objAddress->State; $rblAddress->SelectedIndex = 1; } // It has not -- let's default to having the address be presumed correct } else { $txtAddress1->Enabled = false; $txtAddress2->Enabled = false; $txtCity->Enabled = false; $lstState->Enabled = false; $txtZipCode->Enabled = false; } // No rblAddress - so let's update the address1 label to match the form question's question text } else { $txtAddress1->Name = $objFormQuestion->Question; } } break; case FormQuestionType::Age: $txtAge = new QIntegerTextBox($this, $strControlId . 'age'); $txtAge->Name = $objFormQuestion->Question; $txtAge->Minimum = 0; $txtAge->Maximum = 130; $txtAge->MaxLength = 3; if ($objFormAnswer && !is_null($objFormAnswer->IntegerValue)) { $txtAge->Text = $objFormAnswer->IntegerValue; } else { if ($objPerson != null) { if (!$objPerson->DobYearApproximateFlag && $objPerson->Age) { $txtAge->Text = $objPerson->Age; } } } if ($objFormQuestion->RequiredFlag) { $txtAge->Required = true; } $txtAge->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAge; $txtAge->Width = '50px'; break; case FormQuestionType::DateofBirth: $dtxDateOfBirth = new QDateTimeTextBox($this, $strControlId . 'dob'); $dtxDateOfBirth->LabelForInvalid = 'For example, "Mar 20 1977"'; $dtxDateOfBirth->Name = $objFormQuestion->Question; if ($objFormAnswer && !is_null($objFormAnswer->DateValue)) { $dtxDateOfBirth->Text = $objFormAnswer->DateValue->ToString('MMM D YYYY'); } else { if ($objPerson != null) { if (!$objPerson->DobYearApproximateFlag && !$objPerson->DobGuessedFlag && $objPerson->DateOfBirth) { $dtxDateOfBirth->Text = $objPerson->DateOfBirth->ToString('MMM D YYYY'); } } } if ($objFormQuestion->RequiredFlag) { $dtxDateOfBirth->Required = true; } $dtxDateOfBirth->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $dtxDateOfBirth; $dtxDateOfBirth->Width = '150px'; break; case FormQuestionType::Gender: $lstGender = new QListBox($this, $strControlId . 'gender'); $lstGender->Name = $objFormQuestion->Question; $lstGender->AddItem('- Select One -', null); if ($objFormAnswer && $objFormAnswer->TextValue) { $lstGender->AddItem('Male', true, $objFormAnswer->BooleanValue); $lstGender->AddItem('Female', false, !$objFormAnswer->BooleanValue); } else { if ($objPerson != null) { $lstGender->AddItem('Male', true, $objPerson->Gender == 'M'); $lstGender->AddItem('Female', false, $objPerson->Gender == 'F'); } else { $lstGender->AddItem('Male', true, true); // just default to something $lstGender->AddItem('Female', false, false); } } if ($objFormQuestion->RequiredFlag) { $lstGender->Required = true; } $lstGender->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstGender; break; case FormQuestionType::Phone: $objPhoneArray = array(); if ($objPerson != null) { // Add Household Numbers (if applicable) foreach ($objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { foreach ($objHouseholdParticipation->Household->GetCurrentAddress()->GetPhoneArray() as $objPhone) { $objPhoneArray[] = $objPhone; } } // Add Personal Numbers foreach ($objPerson->GetPhoneArray() as $objPhone) { $objPhoneArray[] = $objPhone; } if (count($objPhoneArray)) { $lstPhone = new QListBox($this, $strControlId . 'id'); $lstPhone->ActionParameter = $strControlId . 'phone'; $lstPhone->Name = $objFormQuestion->Question; $lstPhone->AddItem('- Select One -', null); rsort($objPhoneArray); foreach ($objPhoneArray as $objPhone) { $lstPhone->AddItem($objPhone->Number, $objPhone->Id, $objFormAnswer && $objFormAnswer->PhoneId == $objPhone->Id); } $lstPhone->AddItem('- Other... -', false); if ($objFormQuestion->RequiredFlag) { $lstPhone->Required = true; } $lstPhone->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstPhone; $lstPhone->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); } } $txtPhone = new PhoneTextBox($this, $strControlId . 'phone'); $this->objFormQuestionControlArray[] = $txtPhone; $txtPhone->RenderMethod = 'RenderWithName'; // We need to deduce whether or not we should show an explicit text-valued phone number from before if ($objPerson != null) { $blnExplicitlyTextValueOnly = $objFormAnswer && $objFormAnswer->TextValue && (!$lstPhone || !$lstPhone->SelectedValue); } else { $blnExplicitlyTextValueOnly = true; } if (count($objPhoneArray)) { if ($blnExplicitlyTextValueOnly) { $lstPhone->SelectedIndex = count($lstPhone->GetAllItems()) - 1; $txtPhone->Visible = true; $txtPhone->Required = $objFormQuestion->RequiredFlag; $txtPhone->Text = $objFormAnswer->TextValue; } else { $txtPhone->Visible = false; $txtPhone->Required = false; } } else { $txtPhone->Visible = true; $txtPhone->Required = $objFormQuestion->RequiredFlag; $txtPhone->Name = $objFormQuestion->Question; if ($blnExplicitlyTextValueOnly) { $txtPhone->Text = $objFormAnswer ? $objFormAnswer->TextValue : ''; } } break; case FormQuestionType::Email: $objEmailArray = array(); if ($objPerson != null) { // Add Personal Emails foreach ($objPerson->GetEmailArray() as $objEmail) { $objEmailArray[] = $objEmail; } if (count($objEmailArray)) { $lstEmail = new QListBox($this, $strControlId . 'id'); $lstEmail->ActionParameter = $strControlId . 'email'; $lstEmail->Name = $objFormQuestion->Question; $lstEmail->AddItem('- Select One -', null); rsort($objEmailArray); foreach ($objEmailArray as $objEmail) { $lstEmail->AddItem($objEmail->Address, $objEmail->Id, $objFormAnswer && $objFormAnswer->EmailId == $objEmail->Id); } $lstEmail->AddItem('- Other... -', false); if ($objFormQuestion->RequiredFlag) { $lstEmail->Required = true; } $lstEmail->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstEmail; $lstEmail->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); } } $txtEmail = new QEmailTextBox($this, $strControlId . 'email'); $this->strEmailCtrlId = $strControlId . 'email'; $this->objFormQuestionControlArray[] = $txtEmail; $txtEmail->RenderMethod = 'RenderWithName'; // We need to deduce whether or not we should show an explicit text-valued email address from before if ($objPerson != null) { $blnExplicitlyTextValueOnly = $objFormAnswer && $objFormAnswer->TextValue && (!$lstEmail || !$lstEmail->SelectedValue); } else { $blnExplicitlyTextValueOnly = true; } if (count($objEmailArray)) { if ($blnExplicitlyTextValueOnly) { $lstEmail->SelectedIndex = count($lstEmail->GetAllItems()) - 1; $txtEmail->Visible = true; $txtEmail->Required = $objFormQuestion->RequiredFlag; $txtEmail->Text = $objFormAnswer->TextValue; } else { $txtEmail->Visible = false; $txtEmail->Required = false; } } else { $txtEmail->Visible = true; $txtEmail->Required = $objFormQuestion->RequiredFlag; $txtEmail->Name = $objFormQuestion->Question; if ($blnExplicitlyTextValueOnly) { $txtEmail->Text = $objFormAnswer ? $objFormAnswer->TextValue : ''; } } break; case FormQuestionType::ShortText: $txtAnswer = new QTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAnswer; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->TextValue; } break; case FormQuestionType::LongText: $txtAnswer = new QTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->TextMode = QTextMode::MultiLine; $this->objFormQuestionControlArray[] = $txtAnswer; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->TextValue; } break; case FormQuestionType::Number: $txtAnswer = new QIntegerTextBox($this, $strControlId); $txtAnswer->Name = $objFormQuestion->Question; $txtAnswer->Required = $objFormQuestion->RequiredFlag; $txtAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $txtAnswer; $txtAnswer->Width = '50px'; $txtAnswer->MaxLength = 6; if ($objFormAnswer) { $txtAnswer->Text = $objFormAnswer->IntegerValue; } break; case FormQuestionType::YesNo: $chkAnswer = new QCheckBox($this, $strControlId); $chkAnswer->Name = $objFormQuestion->Question; $chkAnswer->Text = trim($objFormQuestion->Options); $chkAnswer->Required = $objFormQuestion->RequiredFlag; $chkAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $chkAnswer; if ($objFormAnswer) { $chkAnswer->Checked = $objFormAnswer->BooleanValue; } break; case FormQuestionType::SingleSelect: $lstAnswer = new QListBox($this, $strControlId); $lstAnswer->Name = $objFormQuestion->Question; $lstAnswer->Required = $objFormQuestion->RequiredFlag; $lstAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $lstAnswer; $lstAnswer->AddItem('- Select One -', null); foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $lstAnswer->AddItem($strItem, $strItem, $objFormAnswer && $objFormAnswer->TextValue == $strItem); } } if ($objFormQuestion->AllowOtherFlag) { $lstAnswer->ActionParameter = $strControlId . 'other'; $lstAnswer->AddAction(new QChangeEvent(), new QAjaxAction('lst_ToggleOther')); $lstAnswer->AddItem('- Other... -', false); $txtAnswer = new QTextBox($this, $strControlId . 'other'); $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->Required = false; $txtAnswer->Visible = false; $this->objFormQuestionControlArray[] = $txtAnswer; } if ($objFormAnswer && strlen($objFormAnswer->TextValue) && !$lstAnswer->SelectedValue) { if ($objFormQuestion->AllowOtherFlag) { $lstAnswer->SelectedIndex = count($lstAnswer->GetAllItems()) - 1; $txtAnswer->Text = $objFormAnswer->TextValue; $txtAnswer->Visible = true; } else { $lstAnswer->AddItem($objFormAnswer->TextValue, $objFormAnswer->TextValue, true); } } break; case FormQuestionType::MultipleSelect: $strAnswerArray = array(); if ($objFormAnswer) { foreach (explode("\n", trim($objFormAnswer->TextValue)) as $strAnswer) { if (strlen($strAnswer = trim($strAnswer))) { $strAnswerArray[$strAnswer] = $strAnswer; } } } // GJS - Change to check boxes instead of multi select $chkAnswer = new QCheckBoxList($this, $strControlId); $chkAnswer->Name = $objFormQuestion->Question; $chkAnswer->RenderMethod = 'RenderWithName'; $this->objFormQuestionControlArray[] = $chkAnswer; foreach (explode("\n", trim($objFormQuestion->Options)) as $strItem) { if (strlen($strItem = trim($strItem))) { $chkAnswer->AddItem($strItem, $strItem, array_key_exists($strItem, $strAnswerArray)); $strAnswerArray[$strItem] = null; unset($strAnswerArray[$strItem]); } } foreach ($strAnswerArray as $strAnswer) { $chkAnswer->AddItem($strAnswer, $strAnswer, true); } if ($objFormQuestion->AllowOtherFlag) { $txtAnswer = new QTextBox($this, $strControlId . 'other'); $txtAnswer->RenderMethod = 'RenderWithName'; $txtAnswer->HtmlBefore = 'Add another option and hit <strong>Enter</strong>:<br/>'; $txtAnswer->Visible = true; $txtAnswer->ActionParameter = $strControlId; $txtAnswer->AddAction(new QEnterKeyEvent(), new QAjaxAction('txtMultipleSelectOther_Enter')); $this->objFormQuestionControlArray[] = $txtAnswer; } break; case FormQuestionType::Instructions: $lblAnswer = new QLabel($this, $strControlId); $lblAnswer->HtmlEntities = false; $lblAnswer->Text = nl2br(QApplication::HtmlEntities(trim($objFormQuestion->Options)), true); if (strlen($strLabel = trim($objFormQuestion->Question))) { $lblAnswer->Name = $strLabel; $lblAnswer->RenderMethod = 'RenderWithName'; } else { $lblAnswer->RenderMethod = 'Render'; } $this->objFormQuestionControlArray[] = $lblAnswer; break; default: throw new Exception('Invalid FormQuestionTypeId: ' . $objFormQuestion->FormQuestionTypeId); } } }