Login Retreive lost passwordRegister
Search

Forum Index / Feedback / Autocomplete with script.aculo.us

[ This topic is solved ]

  honore vasconcelso 03 December 07 / 18:25  
Hello I have just made an tested an add on for your script for auto-complete feature with script.aculo.us. I wish only to give for some one that whant to use it

<?php

/**
 * extend original FormHandler
 */

class FormHandlerExt extends FormHandler {
    
    
/**
     * FormHandler::setAutoCompleteScriptaculous()
     *
     * Set Ajaxconnection  and field for autocomplete field
     *
     * @param string $field: The field which should be auto complete
     * @param array $options: The list of options for the uto complete
     * @return void
     * @access public
     * @author Honoré Vasconcelos, based on original made by Teye Heimans
     */
    
function setAutoCompleteScriptaculous$field$Link )
    {
        static 
$setJS false;

        
// check if the field exists and is a textfield
        
if( !$this->fieldExists($field) || strtolower(get_class$this->_fields[$field][1] )) != 'textfield')
        {
            
trigger_error(
            
'You have to declare the textfield first! '.
            
'The field "'.$field.'" does not exists in the form!',
            
E_USER_WARNING
            
);

            return;
        }

        
// check if the options are correct
        
if( is_array$Link ) )
        {
            
trigger_error'You have to a link to ajax handler!'E_USER_WARNING );
            return;
        }
        
        
        
// add the javascript file if not done yet
        
if( !$setJS )
        {
            
$setJS true;
            
$this->_setJSFH_FHTML_DIR.'js/prototype.js'true );
            
$this->_setJSFH_FHTML_DIR.'js/scriptaculous.js'true );
        }
        
        
// create the javascript object to handle Ajax transfer
        
$js "\n".'new Ajax.Autocompleter("'.$field.'", "'.$field.'_choices", "'.$Link.'", {paramName: "value"});'."\n";
        
$this->_setJS($jsfalsefalse);
        
$this->_fields[$field][1]->_sExtraAfter .="\n<div id=\"".$field."_choices\" class=\"autocomplete\"></div>\n";

    }
}

?>

  Tom Branius 05 December 07 / 08:13  
Hello honore vasconcelso,

your extension looks good. Do you only have this one new function for autocompletion? I want to create an ajax extensioncalss to FH, too.

  honore vasconcelso 05 December 07 / 10:07  
no, for the moment I don't have any other class ext for RH.

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license