Imran Azad
Imran Azad

Reputation: 1404

Symfony - access related table field from within a form

Is it possible to get a property of a related table of a field within a form? I'm trying to get a property called "getIdentifier" which belongs to the OriginalStone model class.

<?php foreach ($form['treatedStones'] as $fields):?>
     <?php $fields['original_stone_id']->renderRow() ?>
<?php endforeach?>

I was hoping I could do something like:

<?php foreach ($form['treatedStones'] as $fields):?>
     <?php $fields['original_stone_id']->getObject()->getIdentifier() ?>
<?php endforeach?>

Thanks

Upvotes: 0

Views: 212

Answers (1)

1ed
1ed

Reputation: 3668

I assume treatedStones is an embedded doctrine form. Try $form->getEmbeddedForm('treatedStones')->getObject()->getOriginalStone()->getIdentifier()

Upvotes: 1

Related Questions