public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { // For backward compatibility with pre-SF-2.1 forms if (array_key_exists('no autocomplete', $other_args) && $other_args['no autocomplete'] == true) { unset($other_args['autocompletion source']); return SFTextInput::getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); } global $sfgTabIndex, $sfgFieldNum; $className = 'sfComboBox'; if ($is_mandatory) { $className .= ' mandatoryField'; } if (array_key_exists('class', $other_args)) { $className .= ' ' . $other_args['class']; } if (array_key_exists('size', $other_args)) { $size = $other_args['size']; } else { $size = '35'; } // There's no direct correspondence between the 'size=' // attribute for text inputs and the number of pixels, but // multiplying by 6 seems to be about right for the major // browsers. $pixel_width = $size * 6 . 'px'; list($autocompleteFieldType, $autocompletionSource) = SFTextWithAutocompleteInput::getAutocompletionTypeAndSource($other_args); // @TODO - that count() check shouldn't be necessary if (array_key_exists('possible_values', $other_args) && count($other_args['possible_values']) > 0) { $values = $other_args['possible_values']; } elseif ($autocompleteFieldType == 'values') { $values = explode(',', $other_args['values']); } else { $values = SFUtils::getAutocompleteValues($autocompletionSource, $autocompleteFieldType); } $autocompletionSource = str_replace("'", "\\'", $autocompletionSource); $optionsText = Html::element('option', array('value' => $cur_value), null, false) . "\n"; foreach ($values as $value) { $optionsText .= Html::element('option', array('value' => $value), $value) . "\n"; } $selectAttrs = array('id' => "input_{$sfgFieldNum}", 'name' => $input_name, 'class' => $className, 'tabindex' => $sfgTabIndex, 'autocompletesettings' => $autocompletionSource, 'comboboxwidth' => $pixel_width); if (array_key_exists('origName', $other_args)) { $selectAttrs['origname'] = $other_args['origName']; } if (array_key_exists('existing values only', $other_args)) { $selectAttrs['existingvaluesonly'] = 'true'; } $selectText = Html::rawElement('select', $selectAttrs, $optionsText); $divClass = 'ui-widget'; if ($is_mandatory) { $divClass .= ' mandatory'; } $text = Html::rawElement('div', array('class' => $divClass), $selectText); return $text; }
/** * Create the HTML and Javascript to display this field within a form */ function formFieldHTML( $form_field, $cur_value ) { // Also get the actual field, with all the semantic information // (type is SFTemplateField, instead of SFFormField) $template_field = $form_field->getTemplateField(); if ( $form_field->isHidden() ) { $text = SFFormUtils::hiddenFieldHTML( $form_field->getInputName(), $cur_value ); } elseif ( $form_field->getInputType() !== '' && array_key_exists( $form_field->getInputType(), $this->mInputTypeHooks ) && $this->mInputTypeHooks[$form_field->getInputType()] != null ) { $funcArgs = array(); $funcArgs[] = $cur_value; $funcArgs[] = $form_field->getInputName(); $funcArgs[] = $form_field->isMandatory(); $funcArgs[] = $form_field->isDisabled(); // last argument to function should be a hash, merging the default // values for this input type with all other properties set in // the form definition, plus some semantic-related arguments $hook_values = $this->mInputTypeHooks[$form_field->getInputType()]; $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] ); $funcArgs[] = $other_args; $text = call_user_func_array( $hook_values[0], $funcArgs ); } else { // input type not defined in form $property_type = $template_field->getPropertyType(); $is_list = ( $form_field->isList() || $template_field->isList() ); if ( $property_type !== '' && array_key_exists( $property_type, $this->mSemanticTypeHooks ) && isset( $this->mSemanticTypeHooks[$property_type][$is_list] ) ) { $funcArgs = array(); $funcArgs[] = $cur_value; $funcArgs[] = $form_field->getInputName(); $funcArgs[] = $form_field->isMandatory(); $funcArgs[] = $form_field->isDisabled(); $hook_values = $this->mSemanticTypeHooks[$property_type][$is_list]; $other_args = $form_field->getArgumentsForInputCall( $hook_values[1] ); $funcArgs[] = $other_args; $text = call_user_func_array( $hook_values[0], $funcArgs ); } else { // anything else $other_args = $form_field->getArgumentsForInputCall(); // special call to ensure that a list input is the right default size if ( $form_field->isList() ) { if ( ! array_key_exists( 'size', $other_args ) ) { $other_args['size'] = 100; } } $text = SFTextInput::getHTML( $cur_value, $form_field->getInputName(), $form_field->isMandatory(), $form_field->isDisabled(), $other_args ); } } return $text; }
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { $other_args['size'] = 4; return parent::getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); }
public static function getParameters() { $params = parent::getParameters(); $params = array_merge($params, self::getAutocompletionParameters()); return $params; }
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args) { // For backward compatibility with pre-SF-2.1 forms if (array_key_exists('no autocomplete', $other_args) && $other_args['no autocomplete'] == true) { unset($other_args['autocompletion source']); return SFTextInput::getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args); } global $sfgTabIndex, $sfgFieldNum, $sfgEDSettings; $className = 'sfComboBox'; if ($is_mandatory) { $className .= ' mandatoryField'; } if (array_key_exists('class', $other_args)) { $className .= ' ' . $other_args['class']; } if (array_key_exists('size', $other_args)) { $size = $other_args['size']; } else { $size = '35'; } if (array_key_exists('values from external data', $other_args)) { $autocompleteSettings = 'external data'; $remoteDataType = null; if (array_key_exists('origName', $other_args)) { $name = $other_args['origName']; } else { $name = $input_name; } $sfgEDSettings[$name] = array(); if ($other_args['values from external data'] != null) { $sfgEDSettings[$name]['title'] = $other_args['values from external data']; } if (array_key_exists('image', $other_args)) { $image_param = $other_args['image']; $sfgEDSettings[$name]['image'] = $image_param; global $edgValues; for ($i = 0; $i < count($edgValues[$image_param]); $i++) { $image = $edgValues[$image_param][$i]; if (strpos($image, "http") !== 0) { $file = wfFindFile($image); if ($file) { $url = $file->getFullUrl(); $edgValues[$image_param][$i] = $url; } else { $edgValues[$image_param][$i] = ""; } } } } if (array_key_exists('description', $other_args)) { $sfgEDSettings[$name]['description'] = $other_args['description']; if (!array_key_exists('size', $other_args)) { $size = '80'; //Set larger default size if description is also there } } } else { list($autocompleteSettings, $remoteDataType) = self::setAutocompleteValues($other_args); } $inputAttrs = array('type' => 'text', 'id' => "input_{$sfgFieldNum}", 'name' => $input_name, 'class' => $className, 'tabindex' => $sfgTabIndex, 'autocompletesettings' => $autocompleteSettings, 'value' => $cur_value, 'size' => $size, 'disabled' => $is_disabled); if (array_key_exists('origName', $other_args)) { $inputAttrs['origname'] = $other_args['origName']; } if (array_key_exists('existing values only', $other_args)) { $inputAttrs['existingvaluesonly'] = 'true'; } if (array_key_exists('placeholder', $other_args)) { $inputAttrs['placeholder'] = $other_args['placeholder']; } if (!is_null($remoteDataType)) { $inputAttrs['autocompletedatatype'] = $remoteDataType; } $inputText = Html::rawElement('input', $inputAttrs); $divClass = 'ui-widget'; if ($is_mandatory) { $divClass .= ' mandatory'; } $text = Html::rawElement('div', array('class' => $divClass), $inputText); return $text; }