Show up Form in template.. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Show up Form in template.. (/showthread.php?tid=33511) |
Show up Form in template.. - El Forum - 08-29-2010 [eluser]AntSteinn[/eluser] I'm trying get login form into my template but I get this error: A PHP Error was encountered Severity: Notice Message: Undefined variable: data Filename: site/header.php Line Number: 25 Controller Code: <?php Forms Model Code: <?php class Forms extends Model { Code for call $data in template header Code: <?php echo $data['header_login_form']; ?> But my login form shows up in corner. Show up Form in template.. - El Forum - 08-29-2010 [eluser]Vega[/eluser] The $data array will be converted into variables when it is passed to the view so in your view you should have: Code: <?php echo $header_login_form; ?> Show up Form in template.. - El Forum - 08-29-2010 [eluser]AntSteinn[/eluser] Awesome! Thanks! --added-- oh, The $data['header_login_form'] = $this->Forms->header_login_form(); print it anyway out so the form go to the left corner and echo $header_login_form; do nothing. in template file Show up Form in template.. - El Forum - 08-29-2010 [eluser]Vega[/eluser] Yeah that is correct the login form view is already loading first... You could load the view in the template instead and just pass the name of the login view from your controller, something like: In controller: Code: $data['login_view'] = 'templates/site/forms/login'; In template header: Code: <?php $this->load->view($login_view); ?> Show up Form in template.. - El Forum - 08-29-2010 [eluser]AntSteinn[/eluser] U're the man ! Thanks |