Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Twig and outputting a form but getting plain text
  • I'm fairly new to FuelPHP (have been using it for less than a week).
    But so far I really like the framework! It has tons of options and is really simple to learn. Unforunately i've run into a brick wall. When I installed Twig as my template engine and tried to output a form i'm just seeing plain text instead of my actual form:
    <form action="http://example.com/index.php/"; accept-sharset="utf-8" method="post">
        <input class="text" name="username" value="My username" type="text" id="form_username" />
    </form>
    
    Controller (home.php):
    $form = \Fuel\Core\Form::open();
    $form .= \Fuel\Core\Form::input('username', 'My username', array('class' => 'text'));
    $form .= \Fuel\Core\Form::close();
    
    return Response::forge(View::forge('home/index.twig', array(
         'form' => $form,
    )));
    
    Template (index.twig):
    {{ form }}
    
    I got plaintext too when using a model and creating a Fieldset.
    The reason why I did it like this was because Fieldset creates a table around the form. Could someone help me with this?
    And is there maybe a better way of creating a form? Mitchell
  • The default security model of FuelPHP is that everything send to a view is encoded to prevent html or js injections. This means that if you intentionally pass html (or js) to a view, you have to disable encoding for that variable.
    return Response::forge(View::forge('home/index.twig')->set('form', $form, false));
    

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion