Author Topic: adding custom fields to contact table  (Read 3475 times)

sinbad

  • Freshman
  • *
  • Posts: 31
    • View Profile
adding custom fields to contact table
« on: December 25, 2008, 10:47:28 am »
Hello,
first thank you for this great application. looks very promising and I can't wait to see where it develops more.

I have added some extra fields to my contacts table with phpMyAdmin and was wondering what are the files I need to look at if I wanted to edit these fields from Opengoo interface?

thanks in advance!

sinbad

  • Freshman
  • *
  • Posts: 31
    • View Profile
Re: adding custom fields to contact table
« Reply #1 on: December 25, 2008, 10:49:50 pm »
I figured the 'companies; table is more appropiate for what I need.
I noticed company_content.php and add_company.php files.

when I tried adding my own db queries I get errors to undefine method in my new getProjectId.

<div class="cardBlock2">
        <div class="link-ico ico-project" style="padding-bottom:3px;">
        <span><?php echo lang('project id') ?>:</span>
   <?php echo clean($company-> getProjectId()) ?>
   </div>

is there an additional file I need to include my added db fields so I can access them?

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: adding custom fields to contact table
« Reply #2 on: December 26, 2008, 10:00:50 am »
If you added columns to the companies table you need to add them in 'application/models/companies/base/BaseCompanies.class.php'. There you will notice a private static property called $columns. There you should add the names of the columns as keys in the array and the data types as values. Then, on BaseCompany.class.php you should add the getters and setters (i.e. functions that return the column values). Those two classes, as their names say, are for the basic stuff. More complex logic, like queries that handle other objects should be put in Companies.class.php and Company.class.php (of course, you can put it wherever you please :)).

Then, in 'application/views/company' you have the HTML files that you need to edit to add and display this new data. In add_company.php you should add the form elements to enter the new data. If you name this form elements as 'company[property]', where 'property' is the name of the database column you added, then that's all you need to do to set the column value as the element's value. If you need to post process this value before putting it into the database you can do so in 'application/controllers/CompanyController.class.php', in functions add_client and edit_client. Finally, in 'application/views/company_content.php' you can display the new data.

Cheers.