1

How to use channel entries api for creating channel entries which contains matrix field, I have a channel which contains some text fields and one matrix field.The channel api works fine when I insert data of text fields but I was not able to find any documentation of how to insert matrix field data. My code looks like this enter image description here

Can any one please help me out?

1 Answer 1

1

I wrote this function... try it out...

private function create_matrix_field($field_id, $type, $name, $label, $required = 'y', $search = 'y')
{
    $matrix_columns = array('site_id'               => $this->EE->config->item('site_id')
                            , 'field_id'            => $field_id
                            , 'var_id'              => null
                            , 'col_name'            => $name
                            , 'col_label'           => $label
                            , 'col_instructions'    => ''
                            , 'col_type'            => $type
                            , 'col_required'        => $required
                            , 'col_search'          => $search
                            );
    $this->EE->db->insert('exp_matrix_cols', $matrix_columns);
    $this->EE->db->query('ALTER TABLE exp_matrix_data ADD col_id_' . $this->EE->db->insert_id() . ' VARCHAR(255)');
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.