Oi Gerson,

Pensei melhor numa coisa.
O fato de chamar uma coluna de has_one não fica claro o tipo de campo
de formulário.
Modifiquei o arquivo Has_one_field e agora no page.php
tenho:
# Fields settings to override default ABCD:
$fields['section_id']['label'] = 'Section';
$fields['section_id']['type'] = 'has_one'; // set a relationship
$fields['section_id']['data'] = array(
                'type'=>'dropdown', // options: dropdown, radio
                'table'=>'section', //set a another table
                'value_colum'=>'id',
                'title_colum'=>'title'
                );

postei o código do Has_one_field.php
http://pastie.textmate.org/private/uct0wmwwaymemqrl6qf3bw

Abs
Edinho Almeida
11 8018-8019



2009/4/16 Edinho Almeida <[email protected]>:
> Oi Gerson,
>
> Brinquei um pouco com o sistema .
> Ainda não sei se gostei muito ou se gostei.
> Estou a pensar....
>
>
> Resolvi o Has One ou seja a página pode ter somente uma Seção.
> Vou colocar aqui para você e a galera opnar.
> Funcionou !!
>
> arquivos:
> application/controllers/page.php  no método ABCD
> nas linhas que configuram a coluna 'section_id' eu substitui por:
> =============================
> # Fields settings to override default ABCD:
> $fields['section_id']['label'] = 'Section';
> $fields['section_id']['type'] = 'has_one'; // load has_one field type
> $fields['section_id']['data'] = array('table'=>'section', // table to
> load data to dropdown
>  'value_colum'=>'id', // data to save in the section_id column
>  'title_colum'=>'title' // data to show in the admin interface
> );
> =============================
>
> arquivo:
> application/fields/Has_one_field.php
> =============================
> <?php
>
> class Has_one_field extends Abcd {
>
>
>    function Has_one_field()
>    {
>        $this->ci =& get_instance();
>    }
>
>        // --------------------------------------------------------------------
>
>        /**
>         * Build the field
>         *
>         */
>        function build($params)
>        {
>                $output = form_label($params['label'], $params['name']);
>
>        // search the values in the table
>        $this->ci->db->select($params['data']['value_colum']." as
> value,".$params['data']['title_colum']." as title");
>        $query = $this->ci->db->get($params['data']['table']);
>
>        $select_data = array();
>        foreach($query->result() as $row)
>        {
>            $select_data[$row->value] = $row->title;
>        }
>
>                $output .= form_dropdown($params['name'], $select_data, 
> $params['value']);
>
>                return $output;
>        }
>
> }
>
> ?>
> =============================
>
> Acho que falta ter a opção de listar a coluna section_id no 'browse' e
> ele trazer o title da tabela 'section'
>
>
> Abs
> Edinho Almeida
> 11 8018-8019
>

_______________________________________________
Lista mailing list
[email protected]
http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br

Responder a