Custom fields crosstalk

I have a weird issue with custom fields in v1.5.4

  1. a custom Quote ‘single choice’ field ‘Project Type’ which looks up in a list of 11 stored values and records one single choice.

  2. a custom Invoice ‘Text’ field ‘Project Number’ to store our internal project code (letters and digits entered by the user and no relation to a value list)

I try to print the ‘Project Number’ with: <?php _htmlsc($custom_fields['invoice']['Project Number']); ?>

When User enter a ‘Project Number’ value which exists in the value list of the ‘Project Type’ field, the ‘Project Type’ related list ‘value’ will be shown in the invoice instead of the ‘Project Number’. When the entered ‘Project Number’ value exceeds the maximum existing ‘Project Type’ value (11 in my case), the correct number is printed. This is very weird!!! and seems to indicate a knot in the relation system (the erroneous text consistently matches the index of the Project Type values).

I deleted and recreated the ‘Project Number’ field and the error remains. Removing the spaces in the names does not help.

Any idea?

The Invoice template code to print the invoice text is:

            <table>
            <?php if(isset($custom_fields['invoice']['Project Title'])) : ?>
                    <tr>
                    <td><i>Project: </i></td>
                    <td><?php _htmlsc($custom_fields['invoice']['Project Title']); ?></td>
                    </tr>
            <?php endif; ?>
    <?php if(isset($custom_fields['invoice']['Project Number'])) : ?>
                    <tr>
                    <td><i>ID: </i></td>
                    <td><?php _htmlsc($custom_fields['invoice']['Project Number']); ?></td>
                    </tr>
            <?php endif; ?>
           <?php if(isset($quote->quote_number)) : ?>
                    <tr>
                    <td><i>Quote: </i></td>
                    <td><?php _htmlsc($quote->quote_number); ?></td>
                    </tr>
          <?php endif; ?>
            <?php if(isset($custom_fields['invoice']['Budget Code'])) : ?>
  			   <tr>
    			       <td><i>Budget Code: </i></td>
            		   <td><?php _htmlsc($custom_fields['invoice']['Budget Code']); ?></td>';
            		   </tr>
          <?php endif; ?>	
            <?php if(isset($custom_fields['quote']['Project Type'])) : ?>
                    <tr>
                    <td><i>Project Type: </i></td>
                    <td><?php _htmlsc($custom_fields['quote']['Project Type']); ?></td>
                    </tr>
          <?php endif; ?>
            </table>

PHP debug added to the template shows the same error project Number Standard instead of entered ‘3’ (‘Standard’ is the 3rd value in ‘Project Type’ !!)

custom fields
Array
(
[invoice] => Array
(
[Project Title] => test
[Budget Code] =>
[Project Number] => Standard
)

Could it be that the colon at the end of some PHP-lines should be a semicolon?

Regards,
Jan

Hélas not, this is a valid syntax (http://php.net/manual/en/control-structures.if.php) to embed if blocks in php tags. The problem is clearly with input in the range of another (normally unrelated) field so it is likely an issue with the helper construct relating tables together badly.
Thanks for the suggestion anyway!