Open jkavalik opened 4 years ago
This is old nette syntax, the correct is:
public function createComponentAbcForm() : AbcForm {
$form = new AbcForm();
// ...
}
@MartkCz I tried that already, does not work for us either, because we have createElements as a separate function call after construct, so when whenAttached()
is called in this case, there is nothing in the multiplier yet. It would have to be some event after createComponent but before handleSignal/fireEvents.. No idea what that could be.
On the other hand removing $this (presenter) from the constructor seems to work fine atm. And moving createElements to constructor before parent::__construct() would be probably acceptable too as we only use the multiplier in a couple of special components and can cover that with some comments to explain the difference to other code.
Hi there. I have same problem. The attached method is called before I am able to add create and remove button. Its called in contributte/forms-multiplier/src/Multiplier.php:516
when the multiplier is assign to the form. I have one kinda solution, but its not super sexy. https://github.com/slischka/forms-multiplier/commit/461ea71a9efb92bd64bda5d45b6e5268919b4c8d
I was thinking about to add some logic to addCreateButton
but its to complex. The result would be multiple calling getHttpData
etc. nad that would not be good.
The multiplier does not work when we create our form like this:
imho because the form is already attached in here so the onAnchor is never called
and the call during onRender is too late for the buttons to react properly and the form goes to onSuccess instead (the
submittedBy
is never set by the buttons in this case).I tried fixing it by calling
whenAttached()
directly when the form is already anchored but that broke something else and the add button was not rendered at all because it was not yet configured.