コード例 #1
0
function hoydaa_auto_complete($field_id, $url, $options = array())
{
    $response = sfContext::getInstance()->getResponse();
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/prototype');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/effects');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/controls');
    $response->addStylesheet(sfConfig::get('sf_prototype_web_dir') . '/css/input_auto_complete_tag');
    $div = '<div id="' . $field_id . '_auto_complete" class="auto_complete"></div>';
    return $div . _auto_complete_field($field_id, $url, $options);
}
コード例 #2
0
/**
 * wrapper for script.aculo.us/prototype Ajax.Autocompleter.
 * @param string name value of input field
 * @param string default value for input field
 * @param array input tag options. (size, autocomplete, etc...)
 * @param array completion options. (use_style, etc...)
 *
 * @return string input field tag, div for completion results, and
 *                 auto complete javascript tags
 */
function input_auto_complete_tag($name, $value, $url, $tag_options = array(), $completion_options = array())
{
    $context = sfContext::getInstance();
    $tag_options = _convert_options($tag_options);
    $response = $context->getResponse();
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/prototype');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/effects');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir') . '/js/controls');
    $comp_options = _convert_options($completion_options);
    if (isset($comp_options['use_style']) && $comp_options['use_style'] == true) {
        $response->addStylesheet(sfConfig::get('sf_prototype_web_dir') . '/css/input_auto_complete_tag');
    }
    $tag_options['id'] = get_id_from_name(isset($tag_options['id']) ? $tag_options['id'] : $name);
    $javascript = tag('input', array_merge(array('type' => 'text', 'name' => $name, 'value' => $value), _convert_options($tag_options)));
    $javascript .= content_tag('div', '', array('id' => $tag_options['id'] . '_auto_complete', 'class' => 'auto_complete'));
    $javascript .= _auto_complete_field($tag_options['id'], $url, $comp_options);
    return $javascript;
}
コード例 #3
0
function input_auto_complete_tag($name, $value, $url, $tag_options = array(), $completion_options = array())
{
    $obj =& get_instance();
    $obj->response->enqueue_js(array('prototype', 'controls', 'effects'));
    $comp_options = _convert_options($completion_options);
    if (isset($comp_options['use_style']) && $comp_options['use_style'] == 'true') {
        $response->addStylesheet('/sf/css/sf_helpers/input_auto_complete_tag');
    }
    $javascript = input_tag($name, $value, $tag_options);
    $javascript .= content_tag('div', '', array('id' => "{$name}_auto_complete", 'class' => 'auto_complete'));
    $javascript .= _auto_complete_field($name, $url, $comp_options);
    return $javascript;
}