Kanboard: Add Fields to Subtasks

by Behnam, Head Developer


Kanboard (https://kanboard.org/) – I love it! It’s a free, Open Source, professional and easy to use project management software with a clean and readable code. Thank You Dear Contributors! I use it both for managing my own projects and as a code base for creating new solutions. 

Today I planned to add some extra fields to subtasks of the Kanboard service that is used for the VCfund.me project we’re currently working on. We’re using the Kanboard APIs to populate data in boards, tasks and subtasks.  

So, we have two steps: 

– Add fields to DB and make Kanboard to view this fields 

– Change the `createSubtask` method of API to fill this new column 

Adding field into DB: 


Kanboard can use several types of relational DBs. We are using SQLite because it’s easy and lightweight. So, follow these steps to add a field to `subtasks` table: 

– Login to Kanboard as admin 

– Go to setting: http://<YOUR_KANBOARD_ROOT>/?controller=ConfigController&action=index 

– Click `Download the database` and save it 

– Extract downloaded file 

– Open the SQLite with a DB client (I use DBeaver) 

– Run `ALTER TABLE subtasks ADD my_new_field TEXT(2000);` 

– Now compress the SQLite file to a .gz file (Ex: gzip db.sqlite) 

– Upload the compressed DB by clicking `Upload the database` in http://<YOUR_KANBOARD_ROOT>/?controller=ConfigController&action=index 

Now the field is added to the subtask table. If you have any other RDBMS you can connect to it and alter the `subtasks` table to add you new field. 

If you want to change the default schema of DB you should change this file: `app/Schema/Sqlite.php` . But we just wanted to add fields to the existing Kanboard. 

View the new field in Subtasks: 


Subtask view PHP file is in `app/Template/subtask/table.php`. add a new `<th>` in `<thead><tr>` and a new `<td>` in `<tbody>` like this: 



      <?= $subtask['image'] ?>



Now save the file and check the web page: http://<YOUR_KANBOARD_ROOT>/?controller=TaskViewController&action=show&task_id=<TASK_ID>&project_id=<PROJECT_ID> 

Change `createSubtask` and `updateSubtask` methods of the API 


Open `app/Api/Procedure/SubtaskProcedure.php`, find `createSubtask` method, add a new argument to the method `$values` array like this: 


public function createSubtask($task_id, $title, $user_id = 0, $time_estimated = 0, $time_spent = 0, $status = 0,$my_new_field= null) 
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'createSubtask', $task_id); 
        $values = array( 
            'title' => $title, 
            'task_id' => $task_id, 
            'user_id' => $user_id, 
            'time_estimated' => $time_estimated, 
            'time_spent' => $time_spent, 
            'my_new_field' => $my_new_field, 
            'status' => $status, 
        list($valid, ) = $this->subtaskValidator->validateCreation($values); 
        return $valid ? $this->subtaskModel->create($values) : false; 


do this for `updateSubtask` method too. 

now you can add a subtask via API with an additional field: 


    "jsonrpc": "2.0", 
    "method": "createSubtask", 
    "id": 191749979, 
    "params": { 
        "id": 1, 
        "task_id": 1, 
    "my_new_field": "Test Field" 


(change ‘my_new_field’ to your preferred field name)  

Easy, isn’t it? 

Leave a Reply

Your email address will not be published. Required fields are marked *