Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fieldset::build - using in views
  • Hey,

    When i try to use: 

    (...)
    $login_form = Fieldset::forge();
    $login_form->add('username', '', array('placeholder' => 'Benutzername oder E-Mail Adresse'), array('required'));
    $login_form->add('password', '', array('placeholder' => 'Kennwort'), array('required'));
    $login_form->add(Config::get('security.csrf_token_key'), Security::fetch_token(), array('type' => 'hidden'), array('required'));
    $login_form->add('submit', '', array('type' => 'submit', 'value' => 'Anmelden'));
    $data['page_data'] = array('login_form' => $login_form->form()->build());
    (...)

    And i print it out in the view using:

    (...)
    <?php echo $page_data['login_form']; ?>
    (...)

    ...I just get the plain HTML-Code and not the Form directly... 


    Hope you can help me!

    Greez :-)
  • HarroHarro
    Accepted Answer
    FuelPHP encodes on output, all data you send from the controller to the view will be encoded for security reasons.

    If you don't want that, you have to send that variable to the view unencoded, using the set_safe() method, or using false as third parameter to set().

    $view->set('login_form', $login_form->form()->build(), false)

    and then in your view

    <?php echo $login_form; ?>
  • Okay! Thank you, it works perfect!!! Is it possible to render the form without an table?

    Greez
  • SyntaxlbSyntaxlb
    Accepted Answer
    Hi,

    You can customize your form template in config/form.php
  • HarroHarro
    Accepted Answer
    to be complete: copy the default from fuel/core/config to app/config, then customize it.
  • Thank you! Great community here just waited 2 minutes :-D

    Greez

Howdy, Stranger!

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

In this Discussion