/**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     if (sizeof($this->multipleChoiceArray) > 1) {
         $div = parent::generateComponentDiv();
     } else {
         $div = parent::generateComponentDiv(false);
     }
     // Case
     // array(array('value' => 'option1', 'label' => 'Option 1', 'checked' => 'checked', 'tip' => 'This is a tip'))
     $multipleChoiceCount = 0;
     foreach ($this->multipleChoiceArray as $multipleChoice) {
         $multipleChoiceValue = isset($multipleChoice['value']) ? $multipleChoice['value'] : '';
         $multipleChoiceLabel = isset($multipleChoice['label']) ? $multipleChoice['label'] : '';
         $multipleChoiceChecked = isset($multipleChoice['checked']) ? $multipleChoice['checked'] : false;
         $multipleChoiceTip = isset($multipleChoice['tip']) ? $multipleChoice['tip'] : '';
         $multipleChoiceDisabled = isset($multipleChoice['disabled']) ? $multipleChoice['disabled'] : '';
         $multipleChoiceInputHidden = isset($multipleChoice['inputHidden']) ? $multipleChoice['inputHidden'] : '';
         $multipleChoiceCount++;
         $div->insert($this->getMultipleChoiceWrapper($multipleChoiceValue, $multipleChoiceLabel, $multipleChoiceChecked, $multipleChoiceTip, $multipleChoiceDisabled, $multipleChoiceInputHidden, $multipleChoiceCount));
     }
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div, $this->id . '-div');
     return $div->__toString();
 }
Ejemplo n.º 2
0
 function getOptions()
 {
     $options = parent::getOptions();
     if ($this->customStyle) {
         $options['options']['customStyle'] = true;
     }
     return $options;
 }
Ejemplo n.º 3
0
 function getOptions()
 {
     $options = parent::getOptions();
     if (!empty($this->emptyValues)) {
         $options['options']['emptyValue'] = $this->emptyValues;
     }
     if (empty($options['options'])) {
         unset($options['options']);
     }
     return $options;
 }
Ejemplo n.º 4
0
 function getOptions()
 {
     $options = parent::getOptions();
     if (!empty($this->emptyValues)) {
         $options['options']['emptyValue'] = $this->emptyValues;
     }
     if ($this->stateDropDown) {
         $options['options']['stateDropDown'] = true;
     }
     if (empty($options['options'])) {
         unset($options['options']);
     }
     return $options;
 }
Ejemplo n.º 5
0
 function getOptions()
 {
     $options = parent::getOptions();
     // Tabbing
     if ($this->allowTabbing) {
         $options['options']['allowTabbing'] = true;
     }
     // Empty value
     if (!empty($this->emptyValue)) {
         $options['options']['emptyValue'] = $this->emptyValue;
     }
     // Auto grow
     if ($this->autoGrow) {
         $options['options']['autoGrow'] = $this->autoGrow;
     }
     return $options;
 }
 function getOptions()
 {
     $options = parent::getOptions();
     // Make sure you have an options array to manipulate
     if (!isset($options['options'])) {
         $options['options'] = array();
     }
     // Mask
     if (!empty($this->mask)) {
         $options['options']['mask'] = $this->mask;
     }
     // Empty value
     if (!empty($this->emptyValue)) {
         $options['options']['emptyValue'] = $this->emptyValue;
     }
     // Clear the options key if there is nothing in it
     if (empty($options['options'])) {
         unset($options['options']);
     }
     return $options;
 }
Ejemplo n.º 7
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Div tag contains everything about the component
     $div = parent::generateComponentDiv();
     // Select tag
     $select = new JFormElement('select', array('id' => $this->id, 'name' => $this->name, 'class' => $this->class));
     // Only use if disabled is set, otherwise will throw an error
     if ($this->disabled) {
         $select->setAttribute('disabled', 'disabled');
     }
     if ($this->multiple) {
         $select->setAttribute('multiple', 'multiple');
     }
     if ($this->size != null) {
         $select->setAttribute('size', $this->size);
     }
     if ($this->width != null) {
         $select->setAttribute('style', 'width:' . $this->width);
     }
     // Check for any opt groups
     $optGroupArray = array();
     foreach ($this->dropDownOptionArray as $dropDownOption) {
         if (isset($dropDownOption['optGroup']) && !empty($dropDownOption['optGroup'])) {
             $optGroupArray[] = $dropDownOption['optGroup'];
         }
     }
     $optGroupArray = array_unique($optGroupArray);
     // Create the optgroup elements
     foreach ($optGroupArray as $optGroup) {
         ${$optGroup} = new JFormElement('optgroup', array('label' => $optGroup));
     }
     // Add any options to their appropriate optgroup
     foreach ($this->dropDownOptionArray as $dropDownOption) {
         if (isset($dropDownOption['optGroup']) && !empty($dropDownOption['optGroup'])) {
             $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
             $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
             $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
             $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
             $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
             ${$dropDownOption['optGroup']}->insert($this->getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled));
         }
     }
     // Add any options that are not in an opt group to the select
     foreach ($this->dropDownOptionArray as $dropDownOption) {
         // Handle optgroup addition - only add the group if you haven't seen it yet
         if (isset($dropDownOption['optGroup']) && !empty($dropDownOption['optGroup']) && !isset(${$dropDownOption['optGroup'] . 'Added'})) {
             $select->insert(${$dropDownOption['optGroup']});
             ${$dropDownOption['optGroup'] . 'Added'} = true;
         } else {
             if (!isset($dropDownOption['optGroup'])) {
                 $optionValue = isset($dropDownOption['value']) ? $dropDownOption['value'] : '';
                 $optionLabel = isset($dropDownOption['label']) ? $dropDownOption['label'] : '';
                 $optionSelected = isset($dropDownOption['selected']) ? $dropDownOption['selected'] : false;
                 $optionDisabled = isset($dropDownOption['disabled']) ? $dropDownOption['disabled'] : false;
                 $optionOptGroup = isset($dropDownOption['optGroup']) ? $dropDownOption['optGroup'] : '';
                 $select->insert($this->getOption($optionValue, $optionLabel, $optionSelected, $optionDisabled));
             }
         }
     }
     // Add the select box to the div
     $div->insert($select);
     // Add any description (optional)
     $div = $this->insertComponentDescription($div);
     // Add a tip (optional)
     $div = $this->insertComponentTip($div, $this->id . '-div');
     return $div->__toString();
 }
Ejemplo n.º 8
0
 /**
  *
  * @return string
  */
 function __toString()
 {
     // Generate the component div
     $componentDiv = parent::generateComponentDiv(!$this->collapseLabelIntoTableHeading);
     // Create the table
     $table = new JFormElement('table', array('class' => 'jFormComponentLikertTable'));
     // Generate the first row
     if ($this->showTableHeading) {
         $tableHeadingRow = new JFormElement('tr', array('class' => 'jFormComponentLikertTableHeading'));
         $tableHeading = new JFormElement('th', array('class' => 'jFormComponentLikertStatementColumn'));
         // Collapse the label into the heading if the option is set
         if ($this->collapseLabelIntoTableHeading) {
             $tableHeadingLabel = new JFormElement('label', array('class' => 'jFormComponentLikertStatementLabel'));
             $tableHeadingLabel->update($this->label);
             // Add the required star to the label
             if (in_array('required', $this->validationOptions)) {
                 $labelRequiredStarSpan = new JFormElement('span', array('class' => $this->labelRequiredStarClass));
                 $labelRequiredStarSpan->update(' *');
                 $tableHeadingLabel->insert($labelRequiredStarSpan);
             }
             $tableHeading->insert($tableHeadingLabel);
         }
         $tableHeadingRow->insert($tableHeading);
         foreach ($this->choiceArray as $choice) {
             $tableHeadingRow->insert('<th>' . $choice['label'] . '</th>');
         }
         $table->insert($tableHeadingRow);
     }
     // Insert each of the statements
     $statementCount = 0;
     foreach ($this->statementArray as $statement) {
         // Set the row style
         if ($statementCount % 2 == 0) {
             $statementRowClass = 'jFormComponentLikertTableRowEven';
         } else {
             $statementRowClass = 'jFormComponentLikertTableRowOdd';
         }
         // Set the statement
         $statementRow = new JFormElement('tr', array('class' => $statementRowClass));
         $statementColumn = new JFormElement('td', array('class' => 'jFormComponentLikertStatementColumn'));
         $statementLabel = new JFormElement('label', array('class' => 'jFormComponentLikertStatementLabel', 'for' => $statement['name'] . '-choice1'));
         $statementColumn->insert($statementLabel->insert($statement['statement']));
         // Set the statement description (optional)
         if (!empty($statement['description'])) {
             $statementDescription = new JFormElement('div', array('class' => 'jFormComponentLikertStatementDescription'));
             $statementColumn->insert($statementDescription->update($statement['description']));
         }
         // Insert a tip (optional)
         if (!empty($statement['tip'])) {
             $statementTip = new JFormElement('div', array('class' => 'jFormComponentLikertStatementTip', 'style' => 'display: none;'));
             $statementColumn->insert($statementTip->update($statement['tip']));
         }
         $statementRow->insert($statementColumn);
         $choiceCount = 1;
         foreach ($this->choiceArray as $choice) {
             $choiceColumn = new JFormElement('td');
             $choiceInput = new JFormElement('input', array('id' => $statement['name'] . '-choice' . $choiceCount, 'type' => 'radio', 'value' => $choice['value'], 'name' => $statement['name']));
             // Set a selected value if defined
             if (!empty($statement['selected'])) {
                 if ($statement['selected'] == $choice['value']) {
                     $choiceInput->setAttribute('checked', 'checked');
                 }
             }
             $choiceColumn->insert($choiceInput);
             // Choice sub labels
             if (!empty($choice['sublabel'])) {
                 $choiceSublabel = new JFormElement('label', array('class' => 'jFormComponentLikertSublabel', 'for' => $statement['name'] . '-choice' . $choiceCount));
                 $choiceSublabel->update($choice['sublabel']);
                 $choiceColumn->insert($choiceSublabel);
             }
             $statementRow->insert($choiceColumn);
             $choiceCount++;
         }
         $statementCount++;
         $table->insert($statementRow);
     }
     $componentDiv->insert($table);
     // Add any description (optional)
     $componentDiv = $this->insertComponentDescription($componentDiv);
     // Add a tip (optional)
     $componentDiv = $this->insertComponentTip($componentDiv, $this->id . '-div');
     return $componentDiv->__toString();
 }