How add create AdditionalActionBlockHtml into massactions in category products grid in magento? - magento

How add create AdditionalActionBlockHtml into massactions in category products grid?
like this status
I founded getAdditionalActionBlockHtml in app/design/adminhtml/default/default/template/widget/grid/massaction.phtml
But I'm dont understand how it's work.
<div class="right">
<div class="entry-edit">
<?php if ($this->getHideFormElement() !== true):?>
<form action="" id="<?php echo $this->getHtmlId() ?>-form" method="post">
<?php endif ?>
<?php echo $this->getBlockHtml('formkey')?>
<fieldset>
<span class="field-row">
<label><?php echo $this->__('Actions') ?></label>
<select id="<?php echo $this->getHtmlId() ?>-select" class="required-entry select absolute-advice local-validation">
<option value=""></option>
<?php foreach($this->getItems() as $_item): ?>
<option value="<?php echo $_item->getId() ?>"<?php echo ($_item->getSelected() ? ' selected="selected"' : '')?>><?php echo $_item->getLabel() ?></option>
<?php endforeach; ?>
</select>
</span>
<span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-hiddens"></span>
<span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-additional"></span>
<span class="field-row">
<?php echo $this->getApplyButtonHtml() ?>
</span>
</fieldset>
<?php if ($this->getHideFormElement() !== true):?>
</form>
<?php endif ?>
</div>
<div class="no-display">
<?php foreach($this->getItems() as $_item): ?>
<div id="<?php echo $this->getHtmlId() ?>-item-<?php echo $_item->getId() ?>-block">
<?php echo $_item->getAdditionalActionBlockHtml() ?>
</div>
<?php endforeach; ?>
</div>
</div>

I decided this via add methods in massactions
public function addMassAction($observer)
{
$block = $observer->getEvent()->getBlock();
if(get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction' && $block->getRequest()->getControllerName() == 'catalog_product')
{
$stores = Mage::getSingleton('adminhtml/system_config_source_store')->toOptionArray();
$block->addItem('export', array(
'label' => Mage::helper("prodestransl")->__("Export"),
'url' => Mage::helper('adminhtml')->getUrl('prod/adminhtml_export/run'),
'additional' => array(
'stores' => array(
'name' => 'stores',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('catalog')->__('Stores'),
'values' => $stores
)
)
));
}
}

Related

validation errors not net to the flashdata in codeigniter

I'm trying to set validation error to the my form using flashdata in codeigniter but i cannot see the error in a view here is my code of view section. I had already read other relative questions close to my this problem but i'm not found a solution!
<?php if($this->session->flashdata('errors')): ?>
<?php echo $this->session->flashdata('errors');?>
<?php endif; ?>
<?php $attributes = array('id'=>'admin_login','class'=>'form-horizontal'); ?>
<?php echo form_open('admin/login', $attributes); ?>
<div class="form-group">
<?php
$lbl = array('class'=>'col-sm-12 col-lg-12 col-md-12 col-xs-12 control-label');
echo form_label('Email','admin_login',$lbl); ?>
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12">
<?php $data = array('
class'=> 'form-control col-sm-12 col-lg-12 col-md-12 col-xs-12',
'name'=> 'email',
'placeholder'=>'Enter your email'
); ?>
<?php echo form_input($data); ?>
</div>
</div>
<div class="form-group">
<?php
echo form_label('Password','admin_login',$lbl); ?>
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12">
<?php $data = array('
class'=> 'form-control',
'name'=> 'password',
'placeholder'=>'Password'
); ?>
<?php echo form_password($data); ?>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-lg-12 col-md-12 col-xs-12">
<?php $data = array('
class'=> 'btn btn-success btn-md center mt-2',
'name'=> 'submit',
'placeholder'=>'Password',
'value'=>'LOGIN',
'type'=>'submit'
); ?>
<center>
<?php echo form_submit($data); ?>
</center>
</div>
</div>
<?php echo form_close(); ?>
This is my controller part it is name of 'admin' method name is login
public function login(){
$this->form_validation->set_rules('email','Email','required');
$this->form_validation->set_rules('password','Password','required');
// check the form has any error (any miss of rules we set in above codes
if($this->form_validation->run() == FALSE){
$this->session->set_flashdata('errors',
validation_errors());
// $this->session->set_flashdata('name','Your message');
// $errors = validation_errors();
// $this->session->set_flashdata('form_error', $errors);
// $this->session->set_flashdata('name','Your message');
// $data = array('errors'=> validation_errors());
// set_userdata() is regular way to set session, it need manually unset, there for we use flashdata
// $this->session->set_flashdata($data);
}else{
echo "its all good";
}
}
i tried so many codes, i commented out what i used so far. I set in autoload section session library also $autoload['libraries'] = array('database','form_validation','session');
Please tell me what is the wrong here.
Please try with the below code.
public function login(){
$this->form_validation->set_rules('email','Email','required');
$this->form_validation->set_rules('password','Password','required');
if($this->form_validation->run() == true){
echo "its all good";
}else{
$this->session->set_flashdata('errors', validation_errors());
}
$this->load->view('Your View Page');
}

Dependent dropdown for department and course

I a working on a dependent dropdown in yii, I want the department dropdown to autoload with the departments depending on what faculty I select, the course dropdown to load with courses once i select a department, the code almost works except that the dropdowns are updating themselves rather than the dropdowns beneath. How can I make them update properly?
this is the
views/site/newuser:
`<div class="row">`
<?php echo $form->labelEx($model,'faculty_id'); ?>
<?php echo $form->dropDownList($model,'faculty_id',
CHtml::listData(Faculty::model()->findAll(),'id','faculty_name'),
array(
'prompt'=>'Select Faculty',
'ajax' => array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('site/loaddepartment'),
'update'=>'#NewUser_faculty_id',
'data'=>array('faculty_id'=>'js:this.value'),)));
?>
<?php echo $form->error($model,'faculty_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'department_id'); ?>
<?php echo $form->dropDownList($model,'department_id',
CHtml::listData(Department::model()->findAll(),'id','department_name'),
array(
'prompt'=>'Select Department',
'ajax' => array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('site/loadcourses'),
'update'=>'#NewUser_department_id',
'data'=>array('department_id'=>'js:this.value'),)));
?>
<?php echo $form->error($model,'department_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'course_id'); ?>
<?php echo CHtml::dropDownList('department_name','', array(), array(
'prompt'=>'Select Course'
)); ?>
<?php echo $form->error($model,'course_id'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
<?php $this->endWidget(); ?>
this is in the controller:
public function actionloaddepartment()
{
$data=Department::model()->findAll('faculty_id=:faculty_id',
array(':faculty_id'=>(int) $_POST['faculty_id']));
$data=CHtml::listData($data,'id','department_name');
echo "<option value=''>Select Department</option>";
foreach($data as $value=>$department_name)
echo CHtml::tag('option', array('value'=>$value),CHtml::encode($department_name),true);
}
public function actionloadcourses()
{
$data=Courses::model()->findAll('department_id=:department_id',
array(':department_id'=>(int) $_POST['department_id']));
$data=CHtml::listData($data,'id','course_name');
echo "<option value=''>Select course</option>";
foreach($data as $value=>$course_name)
echo CHtml::tag('option', array('value'=>$value),CHtml::encode($course_name),true);
}
so, I was able to get a fix, Thank God, here it is, so incase any one might need it
this is the new/views/site/newuser:
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'first_name'); ?>
<?php echo $form->textField($model,'first_name'); ?>
<?php echo $form->error($model,'first_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'last_name'); ?>
<?php echo $form->textField($model,'last_name'); ?>
<?php echo $form->error($model,'last_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'faculty_id'); ?>
<?php echo $form->dropDownList($model,'faculty_id',
CHtml::listData(Faculty::model()->findAll(),'id','faculty_name'),
array(
'prompt'=>'Select Faculty',
'ajax' => array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('site/loaddepartment'),
'update'=>'#department_id',
'data'=>array('faculty_id'=>'js:this.value'
),
)));
?>
<?php echo $form->error($model,'faculty_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'department_id'); ?>
<?php echo CHtml::dropDownList('department_id','', array(),
array(
'ajax' => array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('site/loadcourses'),
'update'=>'#course_id',
'data'=>array('department_id'=>'js:this.value'
),
)))
?>
<?php echo $form->error($model,'department_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'course_id'); ?>
<?php echo CHtml::dropDownList('course_id','', array()
)?>
<?php echo $form->error($model,'course_id'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
</div>
This is the New controller:
public function actionloaddepartment()
{
$data=Department::model()->findAll('faculty_id=:faculty_id',
array(':faculty_id'=>(int) $_POST['faculty_id']));
$data=CHtml::listData($data,'id','department_name');
foreach($data as $value=>$department_name)
echo CHtml::tag('option', array('value'=>$value),CHtml::encode($department_name),true);
}
public function actionloadcourses()
{
$data=Courses::model()->findAll('department_id=:department_id',
array(':department_id'=>(int) $_POST['department_id']));
$data=CHtml::listData($data,'id','course_name');
foreach($data as $value=>$course_name)
echo CHtml::tag('option', array('value'=>$value),CHtml::encode($course_name),true);
}

Magento - Controller to Ajax Estimate Shipping: Load Block and display phtml

I copied estimatePostAction and made estimateAjaxPostAction (overriding core - I did not hack the core). The controller action works as well (class Mage_Checkout_CartController).
Now I want to get/create a block for replacing shipping block after estimate shipping with ajax. I tried this:
public function estimateAjaxPostAction()
{
$country = (string) $this->getRequest()->getParam('country_id');
$postcode = (string) $this->getRequest()->getParam('estimate_postcode');
$city = (string) $this->getRequest()->getParam('estimate_city');
$regionId = (string) $this->getRequest()->getParam('region_id');
$region = (string) $this->getRequest()->getParam('region');
$this->_getQuote()->getShippingAddress()
->setCountryId($country)
->setCity($city)
->setPostcode($postcode)
->setRegionId($regionId)
->setRegion($region)
->setCollectShippingRates(true);
$this->_getQuote()->save();
//$this->_goBack();
$this->loadLayout();
$block = $this->getLayout()->createBlock('Mage_Checkout_Block_Cart_Shipping','checkout.cart.shipping.ajax',array('template' => 'checkout/cart/shipping.phtml'));
if($block) {
$response = array();
$response['shipping'] = $block->toHtml();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
}
}
The block checkout.cart.shipping.ajax was created. But toHtml() returns nothing.
My JSON returns:
{"shipping":""}
Why toHtml method doesn't work?
Edit: My block code (checkout/cart/shipping.phtml)
<?php /** #var $this Mage_Checkout_Block_Cart_Shipping */ ?>
<div class="row contem-shipping">
<div class="col-xs-10 shipping">
<div class="text-ship">
<h2><?php echo $this->__('Calcular o frete:') ?></h2>
<p><?php echo $this->__('Insira o CEP do endereço<br />no campo ao lado.') ?></p>
</div>
<div class="shipping-form">
<form action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>" method="post" id="shipping-zip-form">
<ul class="form-list">
<li class="no-display">
<div class="input-box">
<?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getEstimateCountryId()) ?>
</div>
</li>
<?php if($this->getStateActive()): ?>
<li>
<label for="region_id"<?php if ($this->isStateProvinceRequired()) echo ' class="required"' ?>><?php if ($this->isStateProvinceRequired()) echo '<em>*</em>' ?><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" style="display:none;"<?php echo ($this->isStateProvinceRequired() ? ' class="validate-select"' : '') ?>>
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<script type="text/javascript">
//<![CDATA[
$('region_id').setAttribute('defaultValue', "<?php echo $this->getEstimateRegionId() ?>");
//]]>
</script>
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getEstimateRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
</div>
</li>
<?php endif; ?>
<?php if($this->getCityActive()): ?>
<li>
<label for="city"<?php if ($this->isCityRequired()) echo ' class="required"' ?>><?php if ($this->isCityRequired()) echo '<em>*</em>' ?><?php echo $this->__('City') ?></label>
<div class="input-box">
<input class="input-text<?php if ($this->isCityRequired()):?> required-entry<?php endif;?>" id="city" type="text" name="estimate_city" value="<?php echo $this->escapeHtml($this->getEstimateCity()) ?>" />
</div>
</li>
<?php endif; ?>
<li>
<div class="input-box">
<input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()):?> required-entry<?php endif;?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo $this->escapeHtml($this->getEstimatePostcode()) ?>" />
</div>
</li>
</ul>
<div class="buttons-set">
<button id="button-cep" style="width: 100px;" type="button" title="<?php echo $this->__('Get a Quote') ?>" onclick="calculaFreteAjax(jQuery('#postcode').val()); return false;" class="btn btn-2 btn-2a"><?php echo $this->__('Get a Quote') ?></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
//]]>
</script>
<?php $_shippingRateGroups = $this->getEstimateRates(); ?>
<?php if ($_shippingRateGroups): ?>
<form id="co-shipping-method-form" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>">
<dl class="sp-methods">
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
<dd>
<ul>
<?php foreach ($_rates as $_rate): ?>
<li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"';?>>
<?php if ($_rate->getErrorMessage()): ?>
<?php echo $this->escapeHtml($_rate->getErrorMessage()) ?>
<?php else: ?>
<input name="estimate_method" type="radio" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php endforeach; ?>
</dl>
</form>
<?php endif; ?>
<script type="text/javascript">
//<![CDATA[
var coShippingMethodForm = new VarienForm('shipping-zip-form');
var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;
coShippingMethodForm.submit = function () {
var country = $F('country');
var optionalZip = false;
for (i=0; i < countriesWithOptionalZip.length; i++) {
if (countriesWithOptionalZip[i] == country) {
optionalZip = true;
}
}
if (optionalZip) {
$('postcode').removeClassName('required-entry');
}
else {
$('postcode').addClassName('required-entry');
}
return VarienForm.prototype.submit.bind(coShippingMethodForm)();
}
//]]>
</script>
</div>
</div>
<div class="col-xs-6">
<?php
$totalItemsInCart = Mage::helper('checkout/cart')->getItemsCount(); //total items in cart
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = $totals["subtotal"]->getValue(); //Subtotal value
$grandtotal = $totals["grand_total"]->getValue(); //Grandtotal value
if(isset($totals['discount']) && $totals['discount']->getValue()) {
$discount = $totals['discount']->getValue(); //Discount value if applied
} else {
$discount = '';
}
$shipping = Mage::helper('checkout')->getQuote()->getShippingAddress()->getData();
$tax = $shipping["shipping_amount"];
/*if( $totals["tax"]->getValue()) {
$tax = $totals["tax"]->getValue(); //Tax value if present
} else {
$tax = '';
}*/
?>
<table class="totals-cart">
<tr>
<td class="total-tile">
Subtotal do pedido:
</td>
<td class="total-price">
<?php echo Mage::helper('core')->currency($subtotal, true, false); ?>
</td>
</tr>
<tr>
<td class="total-tile">
Frete:
</td>
<td class="total-price">
<?php echo Mage::helper('core')->currency($tax, true, false); ?>
</td>
</tr>
<?php if ($discount):?>
<tr>
<td class="total-tile">
Desconto:
</td>
<td class="total-price">
<?php echo Mage::helper('core')->currency($discount, true, false); ?>
</td>
</tr>
<?php endif;?>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-16">
<div class="grand-total">
<p class="text">Total:</p>
<p class="price"><?php echo Mage::helper('core')->currency($grandtotal, true, false);?></p>
</div>
</div>
</div>
<script type="text/javascript">
function calculaFreteAjax(cep) {
jQuery('.contem-shipping .shipping').html('<span class="remove-frete" style="display: block; margin: 0 auto; width: 20px;" id="login-please-wait"><img src="http://sites.xpd.com.br/cpaps/skin/frontend/xpd/default/images/opc-ajax-loader.gif" class="v-middle" alt=""/></span>');
var param = {'country_id': 'BR','estimate_postcode': cep};
console.log(param);
jQuery.ajax({
type: "GET",
url: '<?php echo Mage::getBaseUrl().'checkout/cart/estimateAjaxPost/'; ?>', //My Custom Controller
data: param,
success: function(response) {
response = jQuery.parseJSON(response);
if(response.shipping) {
jQuery('.contem-shipping').parent().html(response.shipping);
}
else {
alert('Falha ao calcular o frete. Tente novamente.');
}
}
});
jQuery('#co-shipping-method-form dd input.radio').click(function(){
//I will submit the shipping method selected
});
}
</script>
Denis... I have modify code please check
public function estimateAjaxPostAction()
{
$country = (string) $this->getRequest()->getParam('country_id');
$postcode = (string) $this->getRequest()->getParam('estimate_postcode');
$city = (string) $this->getRequest()->getParam('estimate_city');
$regionId = (string) $this->getRequest()->getParam('region_id');
$region = (string) $this->getRequest()->getParam('region');
$this->_getQuote()->getShippingAddress()
->setCountryId($country)
->setCity($city)
->setPostcode($postcode)
->setRegionId($regionId)
->setRegion($region)
->setCollectShippingRates(true);
$this->_getQuote()->save();
$response = array();
$response['shipping']=$this->eastmatesajax();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
}
protected function eastmatesajax()
{
$layout=$this->getLayout();
$layout->getMessagesBlock()->setMessages(Mage::getSingleton('checkout/session')->getMessages(true),Mage::getSingleton('catalog/session')->getMessages(true));
$block = $this->getLayout()->createBlock('checkout/cart_shipping')->setTemplate( 'checkout/cart/shipping.phtml');
return $block->toHtml();
}
Updated block issue solved using $this->_getQuote()->collectTotals(); before $this->_getQuote()->save();

Magento Set Multiple Currencies

I have a problem with Magento currency: My code is working fine otherwise, now I want to redirect the page after a change of currency.
Suppose my current URL is http://www.example.com/women/?color=black.
Now, When I change currency it will redirect to: http://www.example.com/women/; so it removes ?color=black.
Code:
if($this->getCurrencyCount()>1): ?>
<div class="block block-currency">
<div class="block-title">
<strong><span><?php echo $this->__('Select Your Currency') ?></span></strong>
</div>
<div class="block-content">
<select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
<?php echo $_name ?> - <?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php endif;
Updated Code:
<?PHP $currentParams = $this->getRequest()->getParams(); ?>
<div style="float:left; margin-top:10px; color:#727478;">
<!--Change 1 to 0 if you wish to output selector always-->
<?php if($this->getCurrencyCount() > 1): ?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name):
$currencyUrl = $this->getSwitchCurrencyUrl($_code);
foreach ($currentParams as $_param) {
$currencyUrl = $this->helper('core/url')->addRequestParam($currencyUrl, $_param);
}
?>
<option value="<?php echo $currencyUrl; ?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif;?>
Updated Code:
<!--Change 1 to 0 if you wish to output selector always-->
<?php if($this->getCurrencyCount() > 1):
$currentParams = $this->getRequest()->getParams();
?>
<span>Select Currency:</span>
<select name="custom-currency-selector" id="custom-currency-selector">
<?php foreach ($this->getCurrencies() as $_code => $_name):
$currencyUrl = $this->helper('core/url')->addRequestParam($this->getSwitchCurrencyUrl($_code),$currentParams)
?>
<option value="<?php echo $currencyUrl ?>"
<?php if($_code == $this->getCurrentCurrencyCode()): ?>
selected="SELECTED"
<?php endif; ?>>
<?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>
You should add these params to the new url:
$currentParams = $this->getRequest()->getParams();
$currencyUrl = $this->helper('core/url')->addRequestParam(
$this->getSwitchCurrencyUrl($_code),
$currentParams
)
Then use $currencyUrl as url for redirect.

codeigniter form_radio()

---- I have solved the radio button problem. now the problem is i need to send the value $thing->quistionNo in the controller along with the answer.---
<?php echo form_open(base_url() . 'things/show');
foreach ($data->result()as $thing) {
echo $thing->questionNo.". ".$thing->question;
$qno =array(
'name' => 'qno',
'id' => 'qno',
'value' => $thing->questionNo
);
//$qno = $thing->questionNo;
var_dump($qno);
?>
<ul>
<li>
<div>
<?php echo form_radio("answer", "1", (set_value("answer") == "1"));
echo $thing->option1; ?>
</div>
</li>
<li>
<div>
<?php echo form_radio("answer", "2", (set_value("answer") == "2"));
echo $thing->option2; ?>
</div>
</li>
<li>
<div>
<?php echo form_radio("answer", "3", (set_value("answer") == "3"));
echo $thing->option3; ?>
</div>
</li>
<li>
<div>
<?php echo form_radio("answer", "4", (set_value("answer") == "4"));
echo $thing->option4; ?>
</div>
</li>
<?php }
echo form_submit(array('name' => 'submit'), 'Submit Answer');
echo form_close();
?>
</body>
</html>
There's a problem with your form_submit.
form_submit has 2 parameters, which accept name and value of the input.
echo form_submit('oksubmit', 'Submit!');
which will produce:
<input type="submit" name="oksubmit" value="Submit!" />
For more information you can refer to here

Resources