Olá,

Eu resolvi esse problema usando uma função no AppModel:

* Get Enum Values
     * Snippet v0.1.3
     * http://cakeforge.org/snippet/detail.php?type=snippet&id=112
     *
     * Gets the enum values for MySQL 4 and 5 to use in selectTag()
     * Tested with PHP 4/5 and CakePHP 1.1.8
     */
    function getEnumValues($columnName=null)
    {
        if ($columnName==null) { return array(); } //no field specified


        //Get the name of the table
        $db =& ConnectionManager::getDataSource($this->useDbConfig);
        $tableName = $db->fullTableName($this, false);


        //Get the values for the specified column (database and
version specific, needs testing)
        $result = $this->query("SHOW COLUMNS FROM {$tableName} LIKE
'{$columnName}'");

        //figure out where in the result our Types are (this varies
between mysql versions)
        $types = null;
        if     ( isset( $result[0]['COLUMNS']['Type'] ) ) { $types =
$result[0]['COLUMNS']['Type']; } //MySQL 5
        elseif ( isset( $result[0][0]['Type'] ) )         { $types =
$result[0][0]['Type'];         } //MySQL 4
        else   { return array(); } //types return not accounted for

        //Get the values
        $values = explode("','",
preg_replace("/(enum)\('(.+?)'\)/","\\2", $types) );

        //explode doesn't do assoc arrays, but cake needs an assoc to
assign values
        $assoc_values = array();
        foreach ( $values as $value ) {
            //leave the call to humanize if you want it to look pretty
            $assoc_values[$value] = Inflector::humanize($value);
        }

        return $assoc_values;

    } //end getEnumValues


Como vc pode ver a solução não é minha, achei a sugestão na internet e
considerei uma alternativa boa já que tenho alguns campos enum ou SET nas
minhas tabelas.

Abraço,
Benito.

2008/1/30 Fênix <[EMAIL PROTECTED]>:

>
> Oi pessoal,
>
> Estou com o seguinte problema.Tenho um campo da tabela que é estado
> civil, este campo é do tipo enum, esta da seguinte forma no banco:
> escivil enum('Solteiro(a)','Casado(a)',''Viuvo(a),'Separado(a)');
>
> e um outro campo do tipo set, onde a pessoa informa se tem algum tipo
> de necessidade especial.
>  prt_nec set('fisica','visual,'auditiva');
>
> ao utilizar o bake vi que ele não consegue gerar o formulário
> corretamente para esses campos.
>
> gostaria de saber como utilizar o helper do html e o que deveria fazer
> para que os valores do banco fossem lidos. e passados corretamente.
> >
>

--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito no Grupo "Cake PHP Português" 
em Grupos do Google.
 Para postar neste grupo, envie um e-mail para [email protected]
 Para cancelar a sua inscrição neste grupo, envie um e-mail para [EMAIL 
PROTECTED]
 Para ver mais opções, visite este grupo em 
http://groups.google.com/group/cake-php-pt?hl=pt-BR
-~----------~----~----~----~------~----~------~--~---

Responder a