/** * Get the the protocol selection section element */ function getProtocolSelectionElement(&$form_state, $disabled, $myvalues, $bFindMatch = TRUE, $sBaseName = 'protocol1', $sDescription = NULL, $bUseAjax = FALSE, $bRequireValue = FALSE, $clues = NULL) { $oPPU = new ProtocolPageUtils(); if ($sBaseName == 'protocol1') { $title = t('Protocol Name'); } else { $title = t('Secondary Protocol Name'); } $root = array('#type' => 'fieldset', '#title' => $title, '#attributes' => array('class' => array('data-entry1-area')), '#disabled' => $disabled); if ($bFindMatch) { $choices = $this->getProtocolChoices($myvalues['procName'], "- Select -", $clues); } else { $choices = $this->getProtocolChoices(""); } //drupal_set_message('>>>choices>>>'.print_r($choices,TRUE)); $element = array('#type' => 'select', '#description' => $sDescription, '#attributes' => array('class' => array('select2')), '#select2' => array()); if (isset($myvalues[$sBaseName . '_nm'])) { if ($disabled) { $element['#value'] = $myvalues[$sBaseName . '_nm']; } else { $element['#default_value'] = $myvalues[$sBaseName . '_nm']; //$element['#required'] = $bRequireValue; } } $element = $oPPU->getFAPI_select_options($element, $choices); if ($bUseAjax) { $element['#ajax'] = array('callback' => 'raptor_fetch_protocol_defaults'); } $root[$sBaseName . '_nm'] = $element; $form['main_fieldset_left'][$sBaseName . '_fieldset'] =& $root; return $form; }
public static function createSelectList($sName, $aChoices, $bDisabled = false, $aStatesEntry = NULL, $myvalues = NULL, $defaultlistvalue_override = NULL) { $element = array('#type' => 'select', '#disabled' => $bDisabled); if ($defaultlistvalue_override !== NULL) { $element['#default_value'] = $defaultlistvalue_override; } else { if (isset($myvalues[$sName])) { $element['#default_value'] = $myvalues[$sName]; //20140819 do not lock the value based on disabled because sometimes we re-enable!!! } } if (!$bDisabled && $aStatesEntry !== NULL) { $element['#states'] = $aStatesEntry; } $oControl = ProtocolPageUtils::getFAPI_select_options($element, $aChoices); //die("$sName -> '".$aMyvalues[$sName]."'<hr>Control info...<hr>".print_r($aMyvalues,true)."<hr>". print_r($aChoices,true) ."<hr>".print_r($oControl,true)); return $oControl; }