I’m not sure there is enough information. But, you’ll need to tell the modal template what post to get the values from and then use that in the acf function
<?php $post_object = get_field('companyname', $post_id); ?>
or at least that’s the way it sounds.