Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:12:55+00:00 2026-05-25T19:12:55+00:00

I have a model called Task defined like this (fields not relevent to question

  • 0

I have a model called Task defined like this (fields not relevent to question removed)

  <?php
  class Model_Task extends Model_Table {
   public $entity_code='vscrum_task';
   public $table_alias='tk';

   function init(){
     parent::init();

  // debug causes error in Ajax in ATK v4.1.1
  // $this->debug(true);
     $this->addField('id')->system(true)->visible(false); 
     $this->addField('task_desc')->mandatory(true)->visible(true);
     $this->addField('tasktype_id')->mandatory(true)->refModel('Model_TaskType');
     $this->addField('team_id')->system(true)->visible(false);

and the refModel tasktype is defined like this (fields not relevent to question removed)

<?php
    class Model_TaskType extends Model_Table {
      public $entity_code='vscrum_tasktype';
      public $table_alias='ty';

      function init(){
     parent::init();

         $this->addField('id')->mandatory(true);
         $this->addField('name')->mandatory(true);
         $this->addField('team_id');

        }   
     }

I have a CRUD which is based on task and is now (thanks to help from Jancha and Romans on stackoverflow) is working fine.

I want to limit the options in the drop down for TaskType to only those tasktypes defined for the user’s team. I tried putting an addCondition in the TaskType Model referencing a session variable i had previously memorized

  $this->addCondition('team_id',$p->api->recall('team_id'));

and also using a direct call to a value for the logged in use

  $this->addCondition('team_id',$p->api->auth->get('team_id'));

but this results in showing the Tasktype fine in the Grid

enter image description here

but leaves it empty for both Edit and Add in the Ajax dialog.

enter image description here

If i remove the addCondition line from the TaskType Model, it shows all values in the list but i will always want this restricted to a subset.

As this is the referred Model and not the Model that the CRUD is based on, any suggestions on how i get this to work as expected ?

I tried Roman’s suggestion of having a model which is the TaskType and a new model extended from that which is the TaskType_Team with the addCondition in it like this

class Model_TaskType_Team extends Model_TaskType {
function init(){
parent::init();

    $this->addCondition('team_id',$p->api->auth->get('team_id'));
  }

for which i needed to create a subdirectory undel Model called TaskType otherwise it didnt find the new Model but the end result is the same. I think this is related to another issue i previously had where the Ajax dialog loses access to $p->api and so doesnt display the restriction (and this is why it works fine for the grid on the same page as that isnt in an ajax dialog but i dont want to use a stickyGet to resolve this for security (dont want to be able to modify the URL to see other teams data) and session variables ($p->auth->memorise and $p->auth->recall) also dont seem work in this case – any further suggestions ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:12:56+00:00Added an answer on May 25, 2026 at 7:12 pm

    Remember that you can extend your models like that. In fact, this is very often used in larger projects.

    class Model_TaskType_Team extends Model_TaskType {
        function init(){
            parent::init();
            $this->addCondition('team_id',$this->api->auth->get('team_id'));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model called Category which looks like this: class Category < ActiveRecord::Base
I have a model called Contact which has_one guest like so. class Contact <
I have the fllowing requirement, I have a model called Task to display user
I have a model called company that has_many users then users belongs_to company. class
I have a model name called StoreEntry. Django admin changes it to look like
I have an entity called Task in my Core Data model. The Task entity
I have a table in my database called Task. Task has the following fields:
I have a model called SimplePage in which I have this line: category =
I have a model called Answer which has a ForeignKey relationship to another model
I have a model called Details, and two controller methods new and create. New

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.