Store category record using JTable instance from controller

by Sajeeb Ahamed   Last Updated September 04, 2019 06:10 AM

I want to store a category record from controller by using JTable. My working code is-

$table = JTable::getInstance('Category');
$data = array('id' => 0, 'parent_id' = 1, 'path' => 'demo', 'level' => 1, 'title' => 'demo');

if ($table->bind($data)) {
    $table->store(true);
}

This code section store the record into #__categories table but problem is it stores parent_id = 0 and level = 0 always. How can I solve this problem?

Tags : category jtable


Related Questions




Category Blog Allows Viewing of all Categories

Updated August 27, 2017 19:10 PM

where is class $tableClass defined

Updated August 20, 2015 18:04 PM