Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Strange issue with form
  • Hi guys, I've got the following code:
    $login_form = \Fieldset::factory('login');
    $login_form->add('username', 'Username');
    $login_form->add('password', 'Password', array('type' => 'password'));
    $data['form'] = \Fieldset::instance('login');
    $this->template->content = \View::factory('profile', $data);
    
    For some reason, when I echo the form in the template, it turns it in the the html-entity'd version. Any ideas how to fix this?
  • Thanks Jelmer! The one thing you guys need in your docs is more examples! That's the only place the framework is lacking. However, since you guys are so quick to respond on the forums, it's almost a non-issue :)
  • It's cast to a string and encoded. You need to pass it like this:
    $this->template->content = \View::factory('profile');
    $this->template->content->set('form', $form, false);
    
  • Thanks! I've decided to use View::$auto_encode = false; in my Controller_Wrapper class for now. How can I change the 'action' of the generated form? Is this possible using the Fieldset class?
  • Multiple options:
    // when outputting, will overwrite any previous action
    $fieldset->build('action/uri');
    
    // using set_config(), currently only possible to set all form_attributes at once (will overwrite previous array)
    $fieldset->set_config('form_attributes', array('action' => 'action/uri'));
    
    // during fieldset construction by passing config array
    $fieldset = Fieldset::factory('login', array('form_attributes' => array('action' => 'action/uri')));
    

Howdy, Stranger!

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

In this Discussion