i have table 'a_installment' and the column is 'id' and 'nama', i try save to 'a_installment' using radio button with this code
etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Veritrans_VtWebbni>
<version>0.1.0</version>
</Veritrans_VtWebbni>
</modules>
<global>
<models>
<vtwebbni>
<class>Veritrans_Vtwebbni_Model</class>
<resourceModel>veritrans_mysql4</resourceModel>
</vtwebbni>
<veritrans_mysql4>
<class>Veritrans_Vtwebbni_Model_Mysql4</class>
<entities>
<vtwebbni>
<table>a_installment</table>
</vtwebbni>
</entities>
</veritrans_mysql4>
</models>
<resources>
<veritrans_write>
<connection>
<use>core_write</use>
</connection>
</veritrans_write>
</resources>
<helpers>
. . .
</helpers>
<blocks>
. . .
</blocks>
<adminhtml>
<layout>
. . .
</layout>
</adminhtml>
</global>
<default>
<payment>
. . .
</payment>
</default>
<frontend>
<routers>
. . .
</routers>
</frontend>
<adminhtml>
<layout>
. . .
</layout>
</adminhtml>
</config>
Model/Vtwebbni.php
<?php
class Veritrans_Vtwebbni_Model_Vtwebbni extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('veritrans/vtwebbni');
}
}
Model/Mysql4/Vtwebbni.php
<?php
class Veritrans_Vtwebbni_Model_Mysql4_Vtwebbni extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
$this->_init('veritrans/vtwebbni', 'id');
}
}
Model/Mysql4/Vtwebbni/Collection.php
<?php
class Veritrans_Vtwebbni_Model_Mysql4_Vtwebbni_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('veritrans/vtwebbni');
}
}
controllers/PaymentController.php
<?php
require_once(Mage::getBaseDir('lib') . '/veritrans-php/Veritrans.php');
class Veritrans_Vtwebbni_PaymentController
extends Mage_Core_Controller_Front_Action {
protected function _getCheckout() {
return Mage::getSingleton('checkout/session');
}
public function redirectAction() { . . . }
public function enable_payment(){ . . . }
public function cancelAction() { . . . }
public function convert_country_code( $country_code ) { . . . }
public function saveAction()
{
//on recuperes les données envoyées en POST
$nama = ''.$this->getRequest()->getPost('nama');
//on verifie que les champs ne sont pas vide
if(isset($nama)&&($nama!='') )
{
//on cree notre objet et on l'enregistre en base
$contact = Mage::getModel('veritrans/vtwebbni');
$contact->setData('nama', $nama);
$contact->save();
}
//on redirige l’utilisateur vers la méthode index du controller indexController
//de notre module <strong>test</strong>
//$this->_redirect('#');
}
}
?>
but my script don't work, no data record on my 'a_installment' table
sorry i forgot this
base/default/template/vtwebbni/form.phtml
<?php
$enable_payment = $this->getEnablePayment();
$direct_debit = $this->getDirectDebit();
$emoney = $this->getEmoney();
$cc = $this->getCreditCard();
$bank_trans = $this->getBankTransfer();
$cstore = $this->getCstore();
?>
<style xmlns="http://www.w3.org/1999/html">. . . </style>
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
<li>. . . </li>
<form action="<?php echo Mage::getUrl('vtwebbni/payment/save') ?>" method="post">
<fieldset>
<li class="control">
<label class="required"><em>*</em><?php echo $this->__('BNI Installment') ?> </label></li>
<li class="control">
<label for="12">
<input type="radio" id="12" name="nama" class="input-radio validate-one-required-by-name" value="12" > <?php echo $this->__('12 month') ?>
</label>
</li>
<li class="control">
<label for="6">
<input type="radio" id="6" name="nama" class="input-radio validate-one-required-by-name" value="6" > <?php echo $this->__('6 month') ?>
</label>
</li>
<li class="control">
<label for="3">
<input type="radio" id="3" name="nama" class="input-radio validate-one-required-by-name" value="3" > <?php echo $this->__('3 month') ?>
</label>
</li>
<li class="control">
<label for="0">
<input type="radio" id="0" name="nama" class="input-radio validate-one-required-by-name" value="0" checked> <?php echo $this->__('Full payment') ?>
</label>
</li>
<li class="control"><input type="submit" value="Save" />
</li>
</fieldset>
</form>
<br>
</ul>