function render(Container $form, $data, $prefix = '') { if ($form->if) { $this->pushStack(new Test($prefix . $form->if), $data); } // Add the forms prefix on $prefix .= $form->prefix; // Group by the form name if it is set if ($form->name) { if (isset($data[$form->name])) { $data = $data[$form->name]; } else { $data = array(); } } // Render the <form> tag if it has an action if ($form->action) { print '<form' . Html::attributes(array('id' => $form->id, 'action' => $form->action, 'method' => $form->method, 'enctype' => $form->upload ? 'multipart/form-data' : NULL)) . '>' . "\n"; // Send a _csrf field with the form print '<input' . Html::attributes(array('type' => 'hidden', 'name' => '_csrf', 'value' => Csrf::generate($form->intent, $form->expire))) . '>' . "\n"; } // Render each of the elements foreach ($form->getElements() as $element) { $this->renderElement($element, $data, $prefix); } // Kill anything remaining on the stack $this->endStack(NULL); // Close the actual form if ($form->action) { print '</form>' . "\n"; } }