Skip to content

Commit

Permalink
Extract template type field (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mzeis committed Oct 8, 2017
1 parent 380c6e0 commit a98e85b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ protected function _prepareForm()
*/
$dependenceBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_form_element_dependence');

$templateTypeField = $this->_addSpecificFields($fieldset, $helper);
$this->_addSpecificFields($fieldset, $helper);
$templateTypeField = $this->_addTemplateTypeField($fieldset, $helper);

$incrementFields['invoice'] = $fieldset->addField('invoiceIncrementId', 'select', array(
'name' => 'invoiceIncrementId',
Expand Down Expand Up @@ -246,7 +247,7 @@ protected function addIncrementIdField(Varien_Data_Form_Element_Fieldset $fields
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Hackathon_EmailPreview_Helper_Data $helper
* @return Varien_Data_Form_Element_Abstract
* @return void
*/
protected function _addSpecificFields(Varien_Data_Form_Element_Fieldset $fieldset, Hackathon_EmailPreview_Helper_Data $helper)
{
Expand All @@ -261,14 +262,19 @@ protected function _addSpecificFields(Varien_Data_Form_Element_Fieldset $fieldse
'name' => 'templateId',
'value' => $templateId
));
}

$templateTypeField = $fieldset->addField('templateType', 'select', array(
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Hackathon_EmailPreview_Helper_Data $helper
* @return Varien_Data_Form_Element_Abstract
*/
protected function _addTemplateTypeField(Varien_Data_Form_Element_Fieldset $fieldset, Hackathon_EmailPreview_Helper_Data $helper)
{
return $fieldset->addField('templateType', 'select', array(
'name' => 'templateType',
'options' => Mage::getModel('hackathon_emailpreview/source_testtypes')->toOptionArray(),
'label' => $helper->__('Template Type'),
));

return $templateTypeField;
}

}
17 changes: 14 additions & 3 deletions app/code/community/Hackathon/EmailPreview/Block/Adminhtml/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ class Hackathon_EmailPreview_Block_Adminhtml_Tool
extends Hackathon_EmailPreview_Block_Adminhtml_Email_Preview
{

/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Hackathon_EmailPreview_Helper_Data $helper
* @return void
*/
protected function _addSpecificFields(Varien_Data_Form_Element_Fieldset $fieldset, Hackathon_EmailPreview_Helper_Data $helper)
{
$fieldset->addField('testType', 'hidden', array(
Expand All @@ -15,13 +20,19 @@ protected function _addSpecificFields(Varien_Data_Form_Element_Fieldset $fieldse
'name' => 'testRecipient',
'label' => $helper->__('Test Recipient'),
));
}

$templateTypeField = $fieldset->addField('templateType', 'select', array(
/**
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Hackathon_EmailPreview_Helper_Data $helper
* @return Varien_Data_Form_Element_Abstract
*/
protected function _addTemplateTypeField(Varien_Data_Form_Element_Fieldset $fieldset, Hackathon_EmailPreview_Helper_Data $helper)
{
return $fieldset->addField('templateType', 'select', array(
'name' => 'templateType',
'options' => Mage::getModel('hackathon_emailpreview/source_templatetypes')->toOptionArray(),
'label' => $helper->__('Template Type'),
));

return $templateTypeField;
}
}

0 comments on commit a98e85b

Please sign in to comment.