Gregwar\Formidable\Form::getHtml PHP Method

getHtml() public method

Convert to HTML
public getHtml ( )
    public function getHtml()
    {
        $html = '';
        if ($this->parserData->needJs()) {
            $html .= $this->getJs();
        }
        $k = 0;
        foreach ($this->parserData->getData() as $data) {
            if ($data instanceof Fields\FileField) {
                $data->getHtml(true);
            }
            $html .= (string) $data;
        }
        if ($html[strlen($html) - 1] != "\n") {
            $html .= "\n";
        }
        return $html;
    }

Usage Example

Example #1
0
 /**
  * Testing that Formidable output given back to Formidable gives the same output
  */
 public function testOutIn()
 {
     $form = $this->getForm('out_in.html');
     $html = $form->getHtml();
     $otherForm = new Form($html);
     $otherHtml = $otherForm->getHtml();
     $this->assertEquals($html, $otherHtml);
 }