forms
forms copied to clipboard
Add common interface to ControlGroup and Container
Common interface declaring getControls()
would be useful for form renderers including DefaultFormRenderer.
Example:
interface IControlContainer
{
/** @return IControl[] */
public function getControls();
}
then, DefaultFormRenderer::renderControls() could look like:
public function renderControls(Nette\Forms\IControlContainer $parent) {
# got rid of this check:
# if (!($parent instanceof Nette\Forms\Container || $parent instanceof Nette\Forms\ControlGroup)) {
# throw new Nette\InvalidArgumentException('Argument must be Nette\Forms\Container or Nette\Forms\ControlGroup instance.');
# }
}
If agreed, I can pullrequest it
Why not make ControlGroup
implement IContainer
? It would also allow to have groups inside groups and get rid of the weird setCurrentGroup()
switching.
Isn’t the left one just more natural?
|
|
Yes it is, but it is a major API change, maybe for Nette 3 one day :) for now, unifying them using interface would be more likely a simple fix of current state.
Maybe it could simplify the whole thing that ControlGroup
and Container
should merge it together.
ControlGroup
is just for form.fieldset? I mean graphic purpose?
ControlGroup is any general group of controls. I think that it is used only for graphic purposes.
What about drop it at all? We could use container for that too?
It is not easy.