![]() |
Xataface 2.0
Xataface Application Framework
|
00001 <?php 00002 $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']['yui_autocomplete'] = array('HTML/QuickForm/yui_autocomplete.php', 'HTML_QuickForm_yui_autocomplete'); 00006 class Dataface_FormTool_yui_autocomplete { 00007 function &buildWidget(&$record, &$field, &$form, $formFieldName, $new=false){ 00008 /* 00009 * This field uses a calendar widget 00010 */ 00011 00012 $widget =& $field['widget']; 00013 $factory =& Dataface_FormTool::factory(); 00014 $el =& $factory->addElement('yui_autocomplete', $formFieldName, $widget['label']); 00015 $el->setProperties($widget); 00016 00017 if ( @$field['vocabulary'] ){ 00018 $el->options = $record->_table->getValuelist($field['vocabulary']); 00019 $el->vocabularyName = $field['vocabulary']; 00020 $el->updateAttributes(array('df:vocabulary'=>$el->vocabularyName)); 00021 } else if ( isset($widget['datasource']) ){ 00022 $datasource =& $widget['datasource']; 00023 if ( isset($datasource['url']) ){ 00024 $el->datasourceUrl = $datasource['url']; 00025 $el->updateAttributes(array('df:datasource'=>$el->datasourceUrl)); 00026 00027 if ( !isset($datasource['resultNode']) ) $datasource['resultNode'] = 'Result'; 00028 $el->resultNode = $datasource['resultNode']; 00029 $el->updateAttributes(array('df:resultNode'=>$el->resultNode)); 00030 00031 if ( !isset($datasource['fieldname']) ) $datasource['fieldname'] = 'df:title'; 00032 $el->queryKeyNode = $datasource['fieldname']; 00033 $el->updateAttributes(array('df:queryKeyNode'=>$el->queryKeyNode)); 00034 00035 if ( !@$datasource['other_fieldnames'] ){ 00036 $el->additionalNodes = array(); 00037 } else { 00038 $el->additionalNodes = array_map('trim', explode(',', $datasource['other_fieldnames'])); 00039 } 00040 $el->updateAttributes(array('df:additionalNodes'=>implode(',',$el->additionalNodes))); 00041 00042 if ( !@$datasource['scriptQueryParam'] ){ 00043 $datasource['scriptQueryParam'] = '-search'; 00044 00045 } 00046 00047 $el->scriptQueryParam = $datasource['scriptQueryParam']; 00048 $el->updateAttributes(array('df:scriptQueryParam'=>$el->scriptQueryParam)); 00049 } 00050 } 00051 00052 return $el; 00053 } 00054 }
1.7.4