To answer your second question first :)
The first and last name information is added via a widget:
app/code/core/Mage/Customer/Block/Widget/Name.php
app/design/frontend/base/default/template/customer/widget/name.phtml
In the registration process these are added via:
echo $this->getLayout()->createBlock('customer/widget_name')
->setObject($this->getFormData())
->setForceUseCustomerAttributes(true)->toHtml()
I guess this was done as the name can be used in many locations, registration, address and checkout. By doing this via a widget you only need once place that adds the form fields and will cut down on duplication of code.
Now onto your first question. To pass data from the database into a textbox I would suggest that you add a new function into your block for this example getPrefcentreData
.
What this function would do would take your snippet of code and load the information that you need from the database.
Then in your template you can simply call something like:
<input type="text" name="your_field" id="your_field" value="<?php $this->getPrefcentreData() ?>" class="text" />
sales_flat_order
is the full name of the table
and so you have to use alias in $installer->getTable()
In $installer->getTable()
parameter like module_alias/table_alias.
In that case try with
$installer->getTable('sales/order')
When you write this it will return table name sales_flat_order
because
module_alias = sales
table_alias = order
EDIT
You can use below script to add new column. It works fine in my system
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('sales/order'),'custom_value', array(
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'nullable' => false,
'length' => 255,
'after' => null, // column name to insert new column after
'comment' => 'Title'
));
$installer->endSetup();
I am using Varien_Db_Ddl_Table::TYPE_TEXT
insted of Varien_Db_Ddl_Table::TYPE_VARCHAR
because TYPE_VARCHAR
is deprecated
You can check @ Varien_Db_Adapter_Pdo_Mysql::$_ddlColumnTypes
And If you specify type TYPE_TEXT
but set length to lets say 255
Magento will create a MySQL
column of VARCHAR
type.
Best Answer
Seems like you want to save a part of model. Set value for the column to be updated and save it. Whwn you submitting data try the following.
The above code will only update the 'images' field with the given value. It won't affect to the other fields of that row.