Ver Mensaje Individual
  #16 (permalink)  
Antiguo 24/04/2011, 10:57
agugut
 
Fecha de Ingreso: agosto-2008
Mensajes: 88
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Symfony autocompletado jquery

Ya solucione el problema, capaz que es de un modo poco ortodoxo. Les paso como me quedo el codigo
buscarSuccess.php
Código PHP:
<?php
slot
(
        
'title',
        
sprintf('> Tipos de Servicio >Buscar'))
?>
<?php include_stylesheets
() ?>
<?php include_javascripts
() ?>
<?php use_javascript
('jquery-1.5.2.min.js'?>
<?php use_javascript
('jquery-ui-1.8.11.custom.min.js'?>
<?php
$arr 
= array();
$j 0;
foreach (
$datos as $i) {
    
$arr[$j] = $i;
    
$j++;
}
$arreglo json_encode($arr);
?>
<script type="text/javascript">
    var myArray = JSON.parse('<?php echo $arreglo?>');
    $(document).ready(function(){
        $("#autoc1").autocomplete({
            source: myArray
        })
    })
</script>
<h1>Tipos de Servicio</h1>
<form action="<?php echo url_for('tiposervicio/buscar'?>" method="post" >
    <div id="busqueda">
        <input type="text" size="20" id="autoc1" name="autoc1"/>
    </div>
    &nbsp;<input type="button" name="Cancelar" value="Cancelar" onClick="javascript:history.back()">
    <input type="submit" value="Buscar" />
</form>
<div id="resultados">
<?php
if ($sql != NULL):
?>
    <hr/>
    <table border="1" cellpadding="1" cellspacing="1" class="tabla">
        <thead>
            <tr class="modo1">
                <th>Tipo de Servicio</th>
                <th>Descripcion</th>
            </tr>
        </thead>
        <tbody>
<?php
    
foreach ($sql as $i):
?>
            <tr class="modo2">
                <td><a href="<?php echo url_for('tiposervicio/show?id=' $i['id']) ?>"><?php echo $i['nombre'?></a></td>
                <td><?php echo $i['descripcionTipoServicio'?></td>
            </tr>

<?php endforeach; ?>

        </tbody>
    </table>
<?php endif; ?>
</div>
executeBuscar:
Código PHP:
    public function executeBuscar(sfWebRequest $request) {
        
$todos Doctrine_Query::create()
                        ->
select('t.*')
                        ->
from('TipoServicio t')
                        ->
fetchArray();
        
$this->datos = array();
        
$j 0;
        foreach (
$todos as $i) {
            
$this->datos[$j] = $i['nombre'];
            
$j+=1;
        }
        
        
$buscar $request->getParameter('autoc1');
        if (
$buscar != NULL) {
            
$this->sql Doctrine_Query::create()
                            ->
select('t.*')
                            ->
from('TipoServicio t')
                            ->
where('t.nombre LIKE?''%' $buscar '%')
                            ->
fetchArray();
        } else {
            
$this->sql NULL;
        }
        
//var_dump($this->sql);*/