I have a series of functions that is suppose to, in the end create a form. they reside in a class such as the following example:
class ExampleForm{
protected $_html = '';
protected $_element;
public function __construct($element){
$this->_element = $element;
protected function _open_form(){
echo $this->_html .= '<form>';
}
public function create_form(){
$this->_open_form()
$this->_html .= $this->_element;
echo "some content";
$this->_close_form()
}
protected function _close_form(){
echo $this->_html .= '</form>'
}
public function __toString(){
return $this->_html;
}
Instantiated as:
$element = 'some element';
new ExampleForm($element);
A more comprehensive example can be seen on Github on line 86 this content gets echoed out, How ever its echoed out side the form.
If you want to see a live action demo of this Then you'll deff wan't me. at the end of the day if you inspect the form on the web page, you'll see above the form opening tag two hidden fields that need to be inside the form tags.
Now one would think this would create a form such as:
<form>
element
some conent
</form>
How ever, what I get is:
some content
<form>
element
</form>
So can some one tell me, based on what I have above why I am getting my "some content" echoed out side the form tag even though I have echoed the opening form tag?
even if I do not echo the opening form tag the "some content" still appears out side the opening form tag.