Ir para conteúdo
Fórum Script Brasil
  • 0

DropDown


luizhbm

Pergunta

Bom galera estou editando um DropDown de cidades e estou com um probleminha , nele e mostrado a cidade selecionada 3 vezes... alguém poderia me ajudar a solucionar esse problema?

<div class="LocationSelectDropDown">
<select onchange="location=this.value">
        <option><?php 
        $location = wm()->get('location.helper')->locationToData(wm()->get('deal.helper')->location());  //Pelo que percebi para solucionar preciso mudar aqui!
        echo $location['city']; ?></option>
<?php foreach($locations as $country=>$locs) { ?>
<?php if($showCountry) {?>
<optgroup label="<?php echo wm()->get('location.helper')->country($country); ?>"> 
<?php foreach($locs as $loc) { $params = wm()->get('location.helper')->urlParams($loc); ?>
        <option class="dropoption" value='<?php echo url('/',$params); ?>'><?php echo $loc['city']; ?></option>
<?php } ?>
</optgroup>
<?php } else { ?>
<?php foreach($locs as $loc) {
$params = wm()->get('location.helper')->urlParams($loc);
$defaultCountry = wm()->get('location.helper')->defaultCountry();
?>
<?php if($country==$defaultCountry) {?>
        <option class="dropoption" value='<?php echo url('/',$params); ?>'><?php echo $loc['city']; ?></option>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
</select>
</div>

Segue uma imagem do problema:

i16056_drop1.png

segue como quero deixá-lo:

i16057_drop2.png

desde já, agradeço!

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

Segue abaixo:

<?php
class WLocationSelectDropDown extends UWidgetWorklet
{
    public function accessRules()
    {
        return array(array('allow','users'=>array('*')));
    }
    
    public function taskRenderOutput()
    {
        $current = wm()->get('deal.helper')->location();
        
        $countries = array();
        $locations = array();
        
        $fixed = $this->param('fixed');
        if($this->param('src') == 'fixed' && is_array($fixed) && count($fixed))
        {
            $fixed = $this->param('fixed');
            $fixed = $fixed?$fixed:array();
            $sql = "SELECT * FROM {{Location}} as t
                WHERE t.id IN (".implode(',',$fixed).") ORDER BY country, city";
            $command = app()->db->createCommand($sql);
        }
        else
        {
            $sql = "SELECT t2.* FROM
                    {{Deal}} as t1,
                    {{Location}} as t2,
                    {{DealLocation}} as t3
                WHERE
                    t1.id=t3.id
                    AND t3.location=t2.id
                AND t1.`active`=1 AND t1.`status`=1
                AND t1.`start` <= :time AND t1.`end` >= :time
                GROUP BY t2.id";
            $command = app()->db->createCommand($sql);
            $command->bindParam(':time',UTimestamp::getNow());
        }
        $dataReader = $command->query();
        while(($row=$dataReader->read())!==false)
        {
            $country = $row['country'];
            $locations[$country][] = $row;
        }
        
        $this->render('selectDropDown',array('locations'=>$locations,'current'=>$current,
            'showCountry'=>!wm()->get('location.helper')->defaultCountry()));
    }
}

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...