Thursday, July 11, 2013

Re: Cakephp is generating empty options to "select" the component

try this one : 

echo $this->Form->input('situacao_venda_id', array('option'=>$situacaoVendas));


On Wed, Jul 10, 2013 at 4:47 PM, AD7six <andydawson76@gmail.com> wrote:
Most likely this is an encoding problem, the labels that are blank contain non-utf8 characters. Investigating along those lines you'll probably find that the db data is not stored correctly as utf8.

AD


On Monday, 8 July 2013 21:47:56 UTC+2, Moacir Cardoso wrote:
I'm having trouble creating combobox components.
The cakephp is generating empty options to "select" the component.

<option value="1"></option>
<option value="2"></option>
<option value="3">Visita</option>
<option value="4">Proposta</option>
<option value="5"></option>
<option value="6"></option>


In the Controller 

$situacaoVendas = $this->SituacaoVenda->find('list');

In the View

echo $this->Form->input('situacao_venda_id');

The html output was

<select name="data[PessoasIteracao][situacao_venda_id]" id="PessoasIteracaoSituacaoVendaId">
<option value="1"></option>
<option value="2"></option>
<option value="3">Visita</option>
<option value="4">Proposta</option>
<option value="5"></option>
<option value="6"></option>
</select>

The query execute by cakephp was

SELECT `SituacaoVenda`.`id`, `SituacaoVenda`.`nome` FROM `crm`.`situacao_vendas` AS `SituacaoVenda` WHERE 1 = 1

the result sql was 

id nome
-------------------
1 Telefone
2 Email
3 Agendamento
4 Visita
5 Anotação

The Model Class

<?php
App::uses('AppModel', 'Model');
/**
 * SituacaoVenda Model
 *
 */
class SituacaoVenda extends AppModel {
/**
 * Display field
 *
 * @var string
 */
public $displayField = 'nome';
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: