Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Module developping
 
luiz_c1
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
São Paulo/Brazil
 

The problem is, I can’t get a form variable to be avaiable at #new_module#/Block/Stardand/standard.php

<?php

class Mage_VisaVbv_Block_Standard_Redirect extends Mage_Core_Block_Abstract {
    
protected function _toHtml() {
        $standard 
Mage::getModel('VisaVbv/standard');

        
$form = new Varien_Data_Form();
        
        
$form->setAction($standard->getVisaVbvUrl())
                        ->
setId('VisaVbv_standard_checkout')
                        ->
setName('VisaVbv_standard_checkout')
                        ->
setMethod('POST')
                        ->
setTarget('_blank')
                        ->
setUseContainer(true);
        
$parcelas $this->getRequest()->getParam('parcelas');  //that is the form variable and how i tried to get it
        
$standard->setParcelas($parcelas);
        foreach (
$standard->getStandardCheckoutFormFields() as $field=>$value{
          $form
->addField($field'hidden', array('name'=>$field'value'=>$value));
        
}
        
        $html 
'<html><body>';
        
$html.= $this->__(utf8_encode('Aguarde...'));
        
$html.= $form->toHtml();
        
$html.= '<script type="text/javascript">document.getElementById("VisaVbv_standard_checkout").submit();</script>';
        
$html.= '</body></html>';

        return 
$html;
    
}
}

that is the form where the user set the variable’s value

<fieldset class="form-list">
    
<?php $_code=$this->getMethodCode() ?>
    <?
      $parcelas 
6;
    
?>
    
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
        <
li>
        <
label for="<?php echo $_code ?>_parcelas" ><?php echo $this->__("Parcelas: "?></label>
        <
select id="<?php echo $_code ?>_parcelas" name="payment[parcelas]">
        
<?php foreach ($this->getParcelas() as $_qty){?>
            
<option value="<?php echo $_qty?><?php if ($_qty == 1):?>selected="selected" <?php endif?>><?php echo $_qty?> <?php if ($_qty == 1)echo utf8_encode('à vista'); } else{echo utf8_encode('vezes');}?></option>
        
<?php }?>
        
</select>
        </
li>
                
        <
li>
          
<?php echo $this->__(utf8_encode('A página de pagamento Visa será aberta ao final da compra.')); ?>
        
</li>
    </
ul>
    
</
fieldset>

Please someone help me?? thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
vianetz
Guru
 
Avatar
Total Posts:  537
Joined:  2008-04-13
Munich, Germany
 

What do you expect?
The name of the select field is “payment[parcelas]” and you try to access the POST variable via “parcelas”.

 
Magento Community Magento Community
Magento Community
Magento Community
 
luiz_c1
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
São Paulo/Brazil
 

I already tryed to use “payment[parcelas]” to retrieve it. It did not work either. I wrote it down based on another module.  Yesterday, i runned a debbug in javascript to see if the variable was been passed through ajax, which it is. It is passed as post as for instance “payment&#x5B;method&#x5D;=VisaVbv_standard&payment;&#x5B;parcelas&#x5D;=3”. It just not save in the payment object as another any other module. This module I am creating is has elements from paypal direct and paypal express.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

If you are using an “array” as a field name, you retrieve it via the array name, not the array index value…

should not be:

$parcelas $this->getRequest()->getParam('parcelas');
//nor
$parcelas $this->getRequest()->getParam('payment[parcelas]');

but rather:

$parcelas $this->getRequest()->getParam('payment');

$parcelas will then be an array.

You’re code doesn’t really make sense though. A drop down item only returns one result, not multiple results which would necessitate the use of an array (which is a common way to collect values of multiple check boxes).

Your code doesn’t even attempt to handle an array of returned values, which makes your naming the select field with an array structure doubly questionable.

 
Magento Community Magento Community
Magento Community
Magento Community
 
luiz_c1
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
São Paulo/Brazil
 

I just wrote like it is in the paypal module, where, its html fields was named in the same way.
After the user advance into the next step these data are passed via Ajax, and it uses a Zend class for request which is suposed to get all payment[field] data ripping off the payment[] part, letting only field(1)=value (,field(2)=value… etc) and add it into the Varien_Object which will be “re-instantiated” as a Visa_VBV type payment. But it is not happening.

 
Magento Community Magento Community
Magento Community
Magento Community
 
luiz_c1
Jr. Member
 
Total Posts:  7
Joined:  2008-09-02
São Paulo/Brazil
 

Solved by making changes on the database… thanks anyway.

 
Magento Community Magento Community
Magento Community
Magento Community
 
hackin
Jr. Member
 
Total Posts:  18
Joined:  2008-12-02
Brasil
 

How was it resolved?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top