Reputation: 3
I have in my Form class:
public function configure()
{
$emb = $this->getEmbeddedForms();
foreach($emb as $key => $form)
{
unset($form['backup']);
}
}
But this not working - not unset. In $emb i have:
oneForm
twoForm
In oneForm and twoForm i have widget backup. I want unset this with getEmbeddedForms. I can't unset this in oneForm.class and twoForm.class.
Upvotes: 0
Views: 726
Reputation: 22756
You should re-embed your form after the unset
.
public function configure()
{
$emb = $this->getEmbeddedForms();
foreach($emb as $key => $form)
{
unset($form['backup']);
// re-embed the current form (it will override the previous one)
$this->embedForm($key, $form);
}
}
Upvotes: 1
Reputation: 2518
No wonder at all. You assign the content of $this->getEmbeddedForms()
the local variable $emb
;-))... Think about it.
So:
<?php
// ...
public function configure() {
foreach($this->getEmbeddedForms() as $key => &$form) {
unset($form['backup']);
}
}
?>
Upvotes: 0