Search code examples
phpproject-managementphabricator

Anyone Added Custom Field in to Task List Show into Dashboard (Phabricator)


I have added due_date into the Manifest Custom Field. Now I want that where ever task list showing to the user then Due Date also displayed over there. I know its very small change in codebase but I am not able to debug this.

enter image description here


Solution

  • I missed a step you need I think to call $fields->readFieldsFromStoage($task) and then I used $field->getValueForStorage()

    I can't say how correct or legal, of even efficient it is, but it does what I think you wanted

     $fields = PhabricatorCustomField::getObjectFields(
                  $task,PhabricatorCustomField::ROLE_VIEW);    
    
    if ($fields){ 
            $fields->readFieldsFromStorage($task);
            foreach ($fields->getFields() as $field){
               if ($field->getModernFieldKey()=='custom.mycustomfield'){
                          // in theory you might be able to add it like this
                          $item->addByline(pht('Due Date:%s', $field->getValueForStorage()));
                          $item->addByline(pht('Assigned: %s', $owner->renderLink()));
               }
            }
    

    Hope that helps