mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-24 21:41:38 +02:00
improving the render to show the tree with indentations
This commit is contained in:
@@ -32,7 +32,7 @@ class Form extends FormElement
|
||||
{
|
||||
$formCode = '';
|
||||
foreach ($this->_elements as $element) {
|
||||
$formCode .= $element->render();
|
||||
$formCode .= $element->render($indent + 1) . PHP_EOL;
|
||||
}
|
||||
|
||||
return $formCode;
|
||||
|
@@ -6,6 +6,6 @@ class InputElement extends FormElement
|
||||
{
|
||||
public function render($indent = 0)
|
||||
{
|
||||
return '<input type="text" />';
|
||||
return str_repeat(' ', $indent) . '<input type="text" />';
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,6 @@ class TextElement extends FormElement
|
||||
{
|
||||
public function render($indent = 0)
|
||||
{
|
||||
return 'this is a text element';
|
||||
return str_repeat(' ', $indent) . 'this is a text element';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user