I have created a table in my database as part of my custom module.
I would like to add user information into a text field from the custom table based on parameters in the address bar.
So far I have created code that will pull the correct information from the database, although this code is placed in the index controller (just to see if it would work). I am now thinking on a more realistic/useable level how to utilise this code.
I have considered putting the code in a block or a model (i'm assuming a block is the thing to use) then calling that from the template file, but I cant work out where to put the code and how to call it.
I am guessing there will need to be more data in my layout file, but I don't know what it should be?
The code to get the data
$params = $this->getRequest()->getParams();
$prefs = Mage::getModel('prefcentre/prefcentre');
$prefs->load($params['id']);
$data = $prefs->getData();
return $data
The layout file
<user_preferences>
<block type="core/template" name="pref_options" output="toHtml" template="ps/prefcentre/preferences.phtml" />
</user_preferences>
The template
<label>First Name<span></span></label>
<input type="text" name="FirstName" id="FirstName" value="<?php //datahere ?>" class="text">
<label>Last Name<span></span></label>
<input type="text" name="LastName" id="LastName" value="<?php //datahere ?>" class="text">
I have tried to work out a solution myself by looking at customer/form/edit.phtml and customer.xml customer_account_edit node but i've not been able to work it out.
When looking at edit.phtml I could only find
<div class="input-box">
<input type="text" name="email" id="email" value="<?php echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text required-entry validate-email" />
</div>
Where would is the first and last name boxes?
Summary of questions
how do I pass data from the database into an textbox
why is first name and last name not on the edit.phtml template