Custom field problem

I have a problem like the one marked as solved, but it doesn’t work for me: [Solved] Adding custom fields to the Client details page
I use invoiceplane1.5.7 and can’t get the output on the pdf. The custom field description in the documentation is not up to date as it mentions a Column description which I don’t get. I have instead an “Order” column.

I added “Company name” to the Client as a custom field and try to retrieve it in the invoice template pdf in two different ways according to two different suggested posts:

<?php if ($invoice->client_custom_company_name) { ?>
            <?php echo $invoice->client_custom_company_name; ?><br>
        <?php } ?>

result: Message: Undefined property:

<?php if ($custom_fields['client']['Company name']) {
            $customfield = $custom_fields['client']['Company name'];
            echo '<div>' . htmlsc($invoice->$customfield) . '</div>';
        } ?>

result: Message: Undefined property: stdClass::$Eco Heating…(name of company)

The last one is obviously close, but still an error message

I am new to php.
Can someone point out to me, what I am doing wrong, please?
Thanks a lot!

Hi there!

I think your over complicating it and confusing yourself a little bit, no need to delcare variables or anything as the system does that for you - you just need to call the right array.

The wiki regarding custom field is still correct as far as I’m aware.

echo $custom_fields['client']['CompanyName']; ?>

Should return the correct value for you :slightly_smiling_face:

1 Like

I’m not sure why company name is not a standard field. I mean, we have fields for date of birth, tax id’s etc, but no company name?

I’d also like to search using company name and I don’t see that happening when company name is a custom field.

I made some small modifications to the code to add company name to the ip_client table and it works like a charm. The next step is to be able to search by company. I want to contribute the code to github but am still a little unsure how to set it up, but will figure it out.

I’m getting off-topic. As nmay1990 said, you have to “echo” the values out. That’s what I got stuck with.

1 Like

Thanks DementedZA. I agree, I would like to see the company name as a standard field and that is how I actually got it to work in my case as the custom field didn’t work.
I haven’t had a look into how to get it into search.
Here is what I did so far:

  1. added column in db client_company_name:
    SQL: ALTER TABLE ip_clients
    ADD COLUMN client_company_name VARCHAR(100) AFTER client_date_modified;
  2. added form.php in application\modules\clients\views above client_name
<?php _trans('client_company_name'); ?>
  1. add in application\language\english\ip_lang.php:
    ‘client_company_name’ => ‘Client Company Name’,

  2. add in application\modules\clients\models\Mdl_clients.php:
    to validation rules:
    ‘client_company_name’ => array(
    ‘field’ => ‘client_company_name’,
    ‘label’ => trans(‘client_company_name’)

  3. add in application\modules\user_clients\models\Mdl_user_clients.php
    public function default_select()
    $this->db->select(‘ip_user_clients.*, ip_users.user_name, ip_clients.client_company_name, ip_clients.client_name, ip_clients.client_surname’);

  4. added the following code:

<?php if ($invoice->client_company_name) { echo '' .htmlsc($invoice->client_company_name) . ''; } else { echo '' . _htmlsc(format_client($invoice)) . ''; } ?>

in all the:
application\views templates (pdf and public)
application\modules\guest\views: payment_information.php and invoices_index.php
application\modules\invoices: (without the ) partial_invoice_table.php and view.php
application\modules\dashboard\views index.php: instead of

<?php if ($invoice->client_company_name) { $ClientCompany = htmlsc($invoice->client_company_name); } else { $ClientCompany = htmlsc(format_client($invoice)) ; } echo anchor('clients/view/' . $invoice->client_id, $ClientCompany); ?>


  1. added it in sql:

Unfortunately I don’t know exactly how to upload it, but maybe this is of help in the meantime for somebody else who wants to add company name to the client profile. It works for me.

Please redirect all further discussion regarding the company name field to Company Name as a standard field as this topic is about a problem with custom fields.

Sorry, moved to Company Name as a standard field

Will discuss more on this link Company name as a standard field