Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
HMVC Request throws Warning
  • Hi,
    I'm calling a controller function thats inside a module from the outside using: echo Request::forge('users/login/index', false)->execute(); in that index function there is: $fieldset = \Fieldset::forge('login'); $fieldset->add('username', 'Username', array(array('required')))->add('password', 'Password', array('type' => 'password', 'maxlength' => 255), array(array('required')));
    $fieldset->add('btnSubmit', '', array('value' => 'Einloggen', 'type' => 'submit', 'tag' => 'button')); However if i do that i get the following errors: Notice: Fieldset with this name exists already, cannot be overwritten. in APPPATH/modules/users/classes/controller/login.php [59]: forgeNotice: Field with this name exists already in this fieldset: "username". in APPPATH/modules/users/classes/controller/login.php [61]: addNotice: Field with this name exists already in this fieldset: "password". in COREPATH/classes/fieldset/field.php [415]: addNotice: Field with this name exists already in this fieldset: "btnSubmit". in APPPATH/modules/users/classes/controller/login.php [63]: add... If i call the function with a regular request through the url in the browser i don't get this error. Any Ideas?
  • So i guess the error occurs because its being called twice.. just wondering why and from where.
  • Fieldset is a multiton, the named fieldset objects will exist for the duration of the entire request. So if you have code that creates a fieldset object called 'login', you can't have other code doing the same (or run the same bit of code twice).
  • Right, i'm just not understanding why it would be called twice..
    i only call it once via: = Request::forge('users/login/index', false)->execute(); With the following code: public function action_index()
    { $view = \View::forge('users/login/index.haml');
    // create the form fieldset, do not add an {open}, a closing ul and a {close}, we have a custom form layout!
    $fieldset = \Fieldset::forge('login');
    \Debug::dump('HIER SAMMA');
    \Log::error("INSIDE");
    $fieldset->add('username', 'Username', array(array('required'))).... i see the Error in the log twice, but the Dump i only see once on the page...
  • Neither do I, but I don't have access to your code. As a debug excercise, you can look inside the Fieldset class to where the error is generated, and before that, add a Debug::backtrace() and a die(), so you can see where the second call is coming from. If that is your HMVC call, you might have to do the backtrace() call in forge(), and dump the backtrace of every instantiation of a fieldset object.

Howdy, Stranger!

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

In this Discussion