Last active
November 5, 2015 16:55
-
-
Save dmsysop/8f347fb7ed561387317c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//No Controller | |
$conditions = array('AnunciantesCategoria.anunciante_id' => $id); | |
$fields = array('AnunciantesCategoria.id'); | |
$AnunciantesCategoriaId = $this->AnunciantesCategoria->find('all', compact('conditions', 'fields')); | |
foreach ($AnunciantesCategoriaId as $k => $v) { | |
$selecionadas[] = $v['AnunciantesCategoria']['id']; | |
} | |
$fields = array('Categoria.id', 'Categoria.nome'); | |
$categorias = $this->Anunciante->Categoria->find('list', compact('fields')); | |
$this->set(compact('categorias', 'selecionadas')); | |
//Na view | |
echo $this->Form->input('categoria_id', array( | |
'between' => '<div class="col-sm-7">', | |
'multiple' => 'multiple', | |
'id' => 'multiselect', | |
'selected' => $selecionadas, | |
'class' => 'gui-input', | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment