how is it nette can echo its forms, which are objects

Notice: This thread is very old.
mikeb
Member | 33
+
0
-

this may be more a php question and showing my ignorance: I'm trying to understand the magic of nette – how is it we can create a form, treat it as an object and then just echo it?

$form = new Form;
$form->addText('name', 'Name:')
echo $form; // <-- why does this not break??

I know it renders using the default renderer by can't understand how and where this becomes a string, or doesn't get an error like ‘object cannot be converted to a string..’ etc
where's the magic hidden? can you point me to some classes and methods that achieve this?

Thanks
Mike

David Matějka
Moderator | 6445
+
0
-

There is __toString method on Form class, see php doc

mikeb
Member | 33
+
0
-

i didn't know about __toString – thanks, I'll follow that through