<?php

/**
 * Render form standalone page.
 *
 * @category Forms
 * @package  Mtc_Form_Builder
 * @author   mtc. Martins Fridenbergs <martins.fridenbergs@mtcmedia.co.uk>
 */
namespace Mtc\Modules\FormBuilder\Classes;

$path = '../../';
require_once $path . 'core/includes/header.inc.php';

if (!empty($_REQUEST['id'])) {
    $form = Form::where('id', $_REQUEST['id'])
        ->with('questions.options')
        ->with('fieldsets.questions')
        ->first();
    if ($form->published) {
        echo $twig->render(
            'FormBuilder/render.form.twig',
            [
                'form' => $form,
                'template' => 'default'
            ]
        );
    } else {
        header("Location: /");
        exit;
    }
}
