本文整理汇总了PHP中Varien_Data_Form::setDataObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form::setDataObject方法的具体用法?PHP Varien_Data_Form::setDataObject怎么用?PHP Varien_Data_Form::setDataObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form
的用法示例。
在下文中一共展示了Varien_Data_Form::setDataObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareLayout
public function _prepareLayout()
{
parent::_prepareLayout();
$form = new Varien_Data_Form();
$form->setDataObject(Mage::registry('current_category'));
$this->setForm($form);
$fieldset = $form->addFieldset('design', array('legend' => Mage::helper('blog')->__('Custom Design'), 'class' => 'fieldset-wide'));
$group = array('custom_apply_to_products', 'custom_design', 'custom_design_from', 'custom_design_to', 'custom_layout', 'custom_layout_update_xml');
if (Mage::registry('current_category')->getLevel() != 1) {
$group[] = 'custom_use_parent_settings';
if (Mage::registry('current_category')->getData('custom_use_parent_settings')) {
Mage::register('disabled', '1');
}
}
$attributes = $this->getCategory()->getAttributes($group);
$this->_setFieldset($attributes, $fieldset);
if (Mage::registry('disabled')) {
Mage::unregister('disabled');
}
if (Mage::getSingleton('adminhtml/session')->getCategoryData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getCategoryData());
Mage::getSingleton('adminhtml/session')->getCategoryData(null);
} elseif (Mage::registry('current_category')) {
$form->setValues(Mage::registry('current_category')->getData());
}
$form->addValues(Mage::registry('category')->getData());
$form->setFieldNameSuffix('general');
$this->setForm($form);
}
示例2: _prepareLayout
protected function _prepareLayout()
{
parent::_prepareLayout();
$model = Mage::getModel('webforms/fieldsets');
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'store' => $this->getRequest()->getParam('store'))), 'method' => 'post'));
$renderer = $this->getLayout()->createBlock('webforms/adminhtml_element_field');
$form->setFieldsetElementRenderer($renderer);
$form->setFieldNameSuffix('fieldset');
$form->setDataObject(Mage::registry('fieldsets_data'));
$fieldset = $form->addFieldset('fieldset_information', array('legend' => Mage::helper('webforms')->__('Information')));
$fieldset->addField('name', 'text', array('label' => Mage::helper('webforms')->__('Name'), 'class' => 'required-entry', 'required' => true, 'name' => 'name'));
$fieldset->addField('position', 'text', array('label' => Mage::helper('webforms')->__('Position'), 'required' => true, 'name' => 'position', 'note' => Mage::helper('webforms')->__('Fieldset position in the form')));
$fieldset->addField('is_active', 'select', array('label' => Mage::helper('webforms')->__('Status'), 'title' => Mage::helper('webforms')->__('Status'), 'name' => 'is_active', 'required' => true, 'options' => Mage::getModel('webforms/webforms')->getAvailableStatuses()));
$form->addField('webform_id', 'hidden', array('name' => 'webform_id', 'value' => 1));
$form->addField('saveandcontinue', 'hidden', array('name' => 'saveandcontinue'));
$fieldset = $form->addFieldset('fieldset_result', array('legend' => Mage::helper('webforms')->__('Results / Notifications')));
$fieldset->addField('result_display', 'select', array('label' => Mage::helper('webforms')->__('Display'), 'title' => Mage::helper('webforms')->__('Display'), 'name' => 'result_display', 'note' => Mage::helper('webforms')->__('Display fieldset name in result / notification messages'), 'values' => Mage::getModel('webforms/fieldsets_display')->toOptionArray()));
if (!$model->getId()) {
$model->setData('is_active', '0');
}
if (Mage::getSingleton('adminhtml/session')->getWebFormsData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getWebFormsData());
Mage::getSingleton('adminhtml/session')->setWebFormsData(null);
} elseif (Mage::registry('fieldsets_data')) {
$form->setValues(Mage::registry('fieldsets_data')->getData());
}
// set default field values
if (!Mage::registry('fieldsets_data')->getId()) {
$form->setValues(array('webform_id' => $this->getRequest()->getParam('webform_id'), 'position' => 10));
}
$form->setUseContainer(true);
Mage::dispatchEvent('webforms_adminhtml_fieldsets_edit_form_prepare_layout', array('form' => $form, 'fieldset' => $fieldset));
$this->setForm($form);
}
示例3: _prepareForm
/**
* Prepare attributes form
*
* @return null
*/
protected function _prepareForm()
{
$group = $this->getGroup();
if ($group) {
$form = new Varien_Data_Form();
// Initialize product object as form property to use it during elements generation
$form->setDataObject(Mage::registry('product'));
$fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName()), 'class' => 'fieldset-wide'));
$attributes = $this->getGroupAttributes();
$this->_setFieldset($attributes, $fieldset, array('gallery'));
$urlKey = $form->getElement('url_key');
if ($urlKey) {
$urlKey->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_form_renderer_attribute_urlkey'));
}
$tierPrice = $form->getElement('tier_price');
if ($tierPrice) {
$tierPrice->setRenderer($this->getLayout()->createBlock('marketplace/adminhtml_catalog_product_edit_tab_price_tier'));
}
$groupPrice = $form->getElement('group_price');
if ($groupPrice) {
$groupPrice->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_group'));
}
// $recurringProfile = $form->getElement('recurring_profile');
// if ($recurringProfile) {
// $recurringProfile->setRenderer(
// $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_recurring')
// );
// }
// Add new attribute button if it is not an image tab
if (!$form->getElement('media_gallery') && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
$headerBar = $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_attributes_create');
$headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
$fieldset->setHeaderBar($headerBar->toHtml());
}
if ($form->getElement('meta_description')) {
$form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
}
$values = Mage::registry('product')->getData();
// Set default attribute values for new product
if (!Mage::registry('product')->getId()) {
foreach ($attributes as $attribute) {
if (!isset($values[$attribute->getAttributeCode()])) {
$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}
}
}
if (Mage::registry('product')->hasLockedAttributes()) {
foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
$element = $form->getElement($attribute);
if ($element) {
$element->setReadonly(true, true);
}
}
}
$form->addValues($values);
$form->setFieldNameSuffix('product');
Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
$this->setForm($form);
}
}
示例4: _prepareLayout
protected function _prepareLayout()
{
parent::_prepareLayout();
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'webform_id' => $this->getRequest()->getParam('webform_id'), 'store' => $this->getRequest()->getParam('store'))), 'method' => 'post'));
$renderer = $this->getLayout()->createBlock('webforms/adminhtml_element_field');
$form->setFieldsetElementRenderer($renderer);
$form->setFieldNameSuffix('logic');
$form->setDataObject(Mage::registry('logic'));
$fieldset = $form->addFieldset('fieldset_information', array('legend' => Mage::helper('webforms')->__('Logic Rule')));
$fieldset->addField('logic_condition', 'select', array('label' => Mage::helper('webforms')->__('Condition'), 'name' => 'logic_condition', 'options' => Mage::getModel('webforms/logic_condition')->getOptions()));
$fieldset->addField('value', 'multiselect', array('label' => Mage::helper('webforms')->__('Trigger value(s)'), 'required' => true, 'name' => 'value', 'note' => Mage::helper('webforms')->__('Select one or multiple trigger values.<br>Please, configure for each locale <b>Store View</b>.'), 'values' => Mage::registry('field')->getOptionsArray()));
$fieldset->addField('action', 'select', array('label' => Mage::helper('webforms')->__('Action'), 'name' => 'action', 'options' => Mage::getModel('webforms/logic_action')->getOptions(), 'note' => Mage::helper('webforms')->__('Action to perform with target elements')));
$fieldset->addField('target', 'multiselect', array('label' => Mage::helper('webforms')->__('Target element(s)'), 'required' => true, 'name' => 'target', 'note' => Mage::helper('webforms')->__('Select one or multiple target elements'), 'values' => Mage::registry('field')->getLogicTargetOptionsArray()));
if (Mage::registry('field')->getType() == 'select/checkbox') {
$fieldset->addField('aggregation', 'select', array('label' => Mage::helper('webforms')->__('Logic aggregation'), 'name' => 'aggregation', 'options' => Mage::getModel('webforms/logic_aggregation')->getOptions()));
}
$fieldset->addField('is_active', 'select', array('label' => Mage::helper('webforms')->__('Status'), 'title' => Mage::helper('webforms')->__('Status'), 'name' => 'is_active', 'options' => Mage::getModel('webforms/webforms')->getAvailableStatuses()));
$form->addField('field_id', 'hidden', array('name' => 'field_id'));
$form->addField('saveandcontinue', 'hidden', array('name' => 'saveandcontinue'));
if (Mage::getSingleton('adminhtml/session')->getWebFormsData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getWebFormsData());
Mage::getSingleton('adminhtml/session')->setWebFormsData(null);
} elseif (Mage::registry('logic')) {
$form->setValues(Mage::registry('logic')->getData());
}
$form->setUseContainer(true);
Mage::dispatchEvent('webforms_adminhtml_logic_edit_form_prepare_layout', array('form' => $form));
$this->setForm($form);
}
示例5: _prepareForm
protected function _prepareForm()
{
$model = Mage::registry('current_item');
$menu = Mage::registry('current_menu');
$form = new Varien_Data_Form();
$form->setDataObject($model);
$this->setForm($form);
$general = $form->addFieldset('menu_form', array('legend' => Mage::helper('menu')->__('General Information')));
if (!$model->getId()) {
$parentId = $this->getRequest()->getParam('parent_id');
if (!$parentId) {
$parentId = null;
}
$general->addField('path', 'hidden', array('name' => 'path', 'value' => $parentId));
} else {
$general->addField('id', 'hidden', array('name' => 'id', 'value' => $model->getId()));
$general->addField('path', 'hidden', array('name' => 'path', 'value' => $model->getPath()));
}
$general->addField('type', 'select', array('label' => Mage::helper('menu')->__('Item Type'), 'name' => 'type', 'values' => Mage::getSingleton('menu/item_type')->getOptionArray(), 'value' => $model->getType(), 'required' => true, 'disabled' => $model->getId() ? true : false));
$general->addField('is_active', 'select', array('label' => Mage::helper('menu')->__('Is Active'), 'name' => 'is_active', 'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(), 'value' => $model->getId() ? $model->getIsActive() : 1, 'required' => true));
$general->addField('name', 'text', array('label' => Mage::helper('menu')->__('Title'), 'class' => 'required-entry', 'required' => true, 'name' => 'name', 'value' => $model->getName()));
if (!Mage::app()->isSingleStoreMode()) {
$field = $general->addField('store_id', 'multiselect', array('name' => 'store_ids[]', 'label' => Mage::helper('menu')->__('Visible in Store View'), 'title' => Mage::helper('menu')->__('Visible in Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true), 'value' => $model->getId() ? $model->getStoreIds() : $menu->getStoreIds()));
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
$field->setRenderer($renderer);
} else {
$general->addField('store_id', 'hidden', array('name' => 'store_ids[]', 'value' => Mage::app()->getStore(true)->getId()));
$model->setStoreId(Mage::app()->getStore(true)->getId());
}
if ($model->getId()) {
$this->addFieldSetByType($form, $model);
}
return parent::_prepareForm();
}
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:34,代码来源:Glace_Menu_Block_Adminhtml_Item_Tab_General.php
示例6: _prepareForm
protected function _prepareForm()
{
$model = Mage::getModel('webforms/webforms');
$form = new Varien_Data_Form();
$renderer = $this->getLayout()->createBlock('webforms/adminhtml_element_field');
$form->setFieldsetElementRenderer($renderer);
$form->setFieldNameSuffix('field');
$form->setDataObject(Mage::registry('field'));
$this->setForm($form);
$fieldset = $form->addFieldset('webforms_form', array('legend' => Mage::helper('webforms')->__('Validation')));
$fieldset->addField('validate_length_min', 'text', array('label' => Mage::helper('webforms')->__('Minimum length'), 'class' => 'validate-number', 'name' => 'validate_length_min'));
$fieldset->addField('validate_length_max', 'text', array('label' => Mage::helper('webforms')->__('Maximum length'), 'class' => 'validate-number', 'name' => 'validate_length_max'));
$fieldset->addField('validate_regex', 'text', array('label' => Mage::helper('webforms')->__('Validation RegEx'), 'name' => 'validate_regex', 'note' => Mage::helper('webforms')->__('Validate with custom regular expression')));
$fieldset->addField('validate_message', 'textarea', array('label' => Mage::helper('webforms')->__('Validation error message'), 'name' => 'validate_message', 'note' => Mage::helper('webforms')->__('Displayed error message text if regex validation fails')));
Mage::dispatchEvent('webforms_adminhtml_fields_edit_tab_design_prepare_form', array('form' => $form, 'fieldset' => $fieldset));
if (Mage::registry('field')->getData('validate_length_min') == 0) {
Mage::registry('field')->setData('validate_length_min', '');
}
if (Mage::registry('field')->getData('validate_length_max') == 0) {
Mage::registry('field')->setData('validate_length_max', '');
}
if (Mage::getSingleton('adminhtml/session')->getWebFormsData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getWebFormsData());
Mage::getSingleton('adminhtml/session')->setWebFormsData(null);
} elseif (Mage::registry('field')) {
$form->setValues(Mage::registry('field')->getData());
}
return parent::_prepareForm();
}
示例7: _prepareForm
/**
* Preparing form elements for editing Entity
*
* @return $this
*/
protected function _prepareForm()
{
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save'), 'method' => 'post', 'enctype' => 'multipart/form-data', 'use_container' => true));
$this->_initDefaultValues();
$entityType = $this->getEntityType();
$entity = $this->getEntity();
$form->setDataObject($entity);
$fieldSet = $form->addFieldset('entity_data', array('legend' => Mage::helper('goodahead_etm')->__("Entity Attributes")));
$attributes = Mage::helper('goodahead_etm')->getVisibleAttributes($entityType);
foreach ($attributes as $attribute) {
/* @var $attribute Mage_Eav_Model_Entity_Attribute */
$attribute->unsIsVisible();
if ($attribute->isSystem()) {
$attribute->setIsVisible(0);
}
}
$this->_setFieldset($attributes, $fieldSet);
if ($entity->getId()) {
$form->addField('entity_id', 'hidden', array('name' => 'entity_id'));
}
$form->setValues($entity->getData());
if ($entityType->getId()) {
$form->addField('entity_type_id', 'hidden', array('name' => 'entity_type_id', 'value' => $entityType->getId()));
}
$form->addField('store_id', 'hidden', array('name' => 'store_id', 'value' => $this->getRequest()->getParam('store')));
$this->setForm($form);
return parent::_prepareForm();
}
示例8: _prepareLayout
public function _prepareLayout()
{
parent::_prepareLayout();
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('_general');
$form->setDataObject($this->getCategory());
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('blog')->__('General Information')));
if (!$this->getCategory()->getId()) {
$parentId = $this->getRequest()->getParam('parent');
if (!$parentId) {
$parentId = EM_Blog_Model_Category::TREE_ROOT_ID;
}
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => $parentId));
} else {
$fieldset->addField('id', 'hidden', array('name' => 'id', 'value' => $this->getCategory()->getId()));
$fieldset->addField('path', 'hidden', array('name' => 'path', 'value' => $this->getCategory()->getPath()));
}
$group = array('name', 'description', 'image', 'page_title', 'meta_keywords', 'meta_description', 'is_active', 'url_key', 'show_image');
$attributes = $this->getCategory()->getAttributes($group);
$this->_setFieldset($attributes, $fieldset);
if ($this->getCategory()->getId()) {
if ($this->getCategory()->getLevel() == 1) {
$fieldset->removeField('url_key');
$fieldset->addField('url_key', 'hidden', array('name' => 'url_key', 'value' => $this->getCategory()->getUrlKey()));
}
}
$form->addValues($this->getCategory()->getData());
$form->setFieldNameSuffix('general');
$this->setForm($form);
}
示例9: _prepareForm
/**
* Prepare form before rendering HTML
*
* @return Mage_Adminhtml_Block_Widget_Form
*/
protected function _prepareForm()
{
$help = Mage::helper('antoinek_slider');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('slider_');
$form->setFieldNameSuffix('slider');
$entity = Mage::registry('current_slider');
$form->setDataObject($entity);
if ($entity->getId()) {
$form->addField('slider_id', 'hidden', array('name' => 'slider_id'));
}
$fieldset = $form->addFieldset('general', array('legend' => $help->__('General Information')));
$fieldset->addField('title', 'text', array('name' => 'title', 'label' => $help->__('Title'), 'title' => $help->__('Title'), 'required' => true));
if (!Mage::app()->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => Mage::helper('cms')->__('Store View'), 'title' => Mage::helper('cms')->__('Store View'), 'required' => true, 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true)));
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', array('name' => 'stores[]', 'value' => Mage::app()->getStore(true)->getId()));
$entity->setStoreId(Mage::app()->getStore(true)->getId());
}
$fieldset->addField('is_active', 'select', array('name' => 'is_active', 'label' => Mage::helper('adminhtml')->__('Status'), 'title' => Mage::helper('adminhtml')->__('Status'), 'required' => true, 'options' => array('1' => Mage::helper('cms')->__('Enabled'), '0' => Mage::helper('cms')->__('Disabled'))));
Mage::dispatchEvent('antoinek_slider_adminhtml_slider_edit_tab_general_prepare_form', array('form' => $form));
$form->setValues($entity->getData());
$this->setForm($form);
return parent::_prepareForm();
}
示例10: _prepareForm
protected function _prepareForm()
{
$form = new Varien_Data_Form();
/**
* Initialize product object as form property
* for using it in elements generation
*/
$form->setDataObject(Mage::registry('product'));
$fieldset = $form->addFieldset('group_fields', array());
$attributes = $this->getGroupAttributes();
$this->_setFieldset($attributes, $fieldset, array('gallery'));
$values = Mage::registry('product')->getData();
/**
* Set attribute default values for new product
*/
if (!Mage::registry('product')->getId()) {
foreach ($attributes as $attribute) {
if (!isset($values[$attribute->getAttributeCode()])) {
$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}
}
}
Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
$form->addValues($values);
$form->setFieldNameSuffix('product');
$this->setForm($form);
}
示例11: _prepareForm
protected function _prepareForm()
{
$model = Mage::getModel('webforms/webforms');
$form = new Varien_Data_Form();
$form->setFieldNameSuffix('form');
$form->setDataObject(Mage::registry('webforms_data'));
$this->setForm($form);
$fieldset = $form->addFieldset('webforms_general', array('legend' => Mage::helper('webforms')->__('General Settings')));
$fieldset->addField('registered_only', 'select', array('label' => Mage::helper('webforms')->__('Registered customers only'), 'title' => Mage::helper('webforms')->__('Registered customers only'), 'name' => 'registered_only', 'required' => false, 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
$fieldset->addField('survey', 'select', array('label' => Mage::helper('webforms')->__('Survey mode'), 'title' => Mage::helper('webforms')->__('Survey mode'), 'name' => 'survey', 'required' => false, 'note' => Mage::helper('webforms')->__('Survey mode allows filling up the form only one time'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
$fieldset->addField('approve', 'select', array('label' => Mage::helper('webforms')->__('Enable approval'), 'title' => Mage::helper('webforms')->__('Enable approval'), 'name' => 'approve', 'required' => false, 'note' => Mage::helper('webforms')->__('Enable approval of results'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
$fieldset->addField('redirect_url', 'text', array('label' => Mage::helper('webforms')->__('Redirect URL'), 'title' => Mage::helper('webforms')->__('Redirect URL'), 'name' => 'redirect_url', 'note' => Mage::helper('webforms')->__('Redirect to specified url after successful submission')));
$fieldset = $form->addFieldset('webforms_email', array('legend' => Mage::helper('webforms')->__('E-mail Settings')));
$fieldset->addField('send_email', 'select', array('label' => Mage::helper('webforms')->__('Send results by e-mail to admin'), 'title' => Mage::helper('webforms')->__('Send results by e-mail to admin'), 'name' => 'send_email', 'required' => false, 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(), 'note' => Mage::helper('webforms')->__('Enable admin notifications. If you have Select/Contact field in the form, e-mail notification will be sent twice: to admin and to selected contact')));
$fieldset->addField('duplicate_email', 'select', array('label' => Mage::helper('webforms')->__('Duplicate results by e-mail to customer'), 'title' => Mage::helper('webforms')->__('Duplicate results by e-mail to customer'), 'note' => Mage::helper('webforms')->__('Enable customer notifications'), 'name' => 'duplicate_email', 'required' => false, 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
$fieldset->addField('email', 'text', array('label' => Mage::helper('webforms')->__('Notification e-mail address'), 'note' => Mage::helper('webforms')->__('If empty default notification e-mail address will be used. You can set multiple addresses comma-separated'), 'name' => 'email'));
$fieldset->addField('email_reply_to', 'text', array('label' => Mage::helper('webforms')->__('Reply-to address for customer'), 'note' => Mage::helper('webforms')->__('Set reply-to parameter in customer notifications'), 'name' => 'email_reply_to'));
$fieldset->addField('add_header', 'select', array('label' => Mage::helper('webforms')->__('Add header to the message'), 'title' => Mage::helper('webforms')->__('Add header to the message'), 'name' => 'add_header', 'note' => Mage::helper('webforms')->__('Add header with Store Group, IP and other information to the message'), 'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray()));
$fieldset = $form->addFieldset('webforms_captcha', array('legend' => Mage::helper('webforms')->__('reCaptcha Settings')));
$fieldset->addField('captcha_mode', 'select', array('label' => Mage::helper('webforms')->__('Captcha mode'), 'title' => Mage::helper('webforms')->__('Captcha mode'), 'name' => 'captcha_mode', 'required' => false, 'note' => Mage::helper('webforms')->__('Default value is set in Forms Settings'), 'values' => Mage::getModel('webforms/captcha_mode')->toOptionArray(true)));
Mage::dispatchEvent('webforms_adminhtml_webforms_edit_tab_settings_prepare_form', array('form' => $form, 'fieldset' => $fieldset));
if (!Mage::registry('webforms_data')->getId()) {
Mage::registry('webforms_data')->setData('send_email', 1);
}
if (Mage::getSingleton('adminhtml/session')->getWebFormsData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getWebFormsData());
Mage::getSingleton('adminhtml/session')->setWebFormsData(null);
} elseif (Mage::registry('webforms_data')) {
$form->setValues(Mage::registry('webforms_data')->getData());
}
return parent::_prepareForm();
}
开发者ID:monarcmoso,项目名称:beta2,代码行数:32,代码来源:SingPost_WebForms_Block_Adminhtml_Webforms_Edit_Tab_Settings.php
示例12: _prepareForm
protected function _prepareForm()
{
$model = Mage::getModel('webforms/webforms');
$form = new Varien_Data_Form();
$form->setFieldNameSuffix('field');
$form->setDataObject(Mage::registry('field'));
$this->setForm($form);
$fieldset = $form->addFieldset('webforms_form', array('legend' => Mage::helper('webforms')->__('Design')));
$fieldset->addField('size', 'select', array('label' => Mage::helper('webforms')->__('Size'), 'name' => 'size', 'values' => Mage::getModel('webforms/fields')->getSizeTypes(), 'note' => Mage::helper('webforms')->__('Standard - two neighbour fields will be merged in one row<br />Wide - field will be wide and single in a row')));
$fieldset->addField('css_class', 'text', array('label' => Mage::helper('webforms')->__('Additional CSS classes for the input element'), 'name' => 'css_class', 'note' => Mage::helper('webforms')->__('You can use it for additional field validation (see Prototype validation classes)')));
$fieldset->addField('css_style', 'text', array('label' => Mage::helper('webforms')->__('Additional CSS style for the input element'), 'name' => 'css_style', 'note' => Mage::helper('webforms')->__('Add custom stylization to the input element')));
// $fieldset = $form->addFieldset('field_result', array(
// 'legend' => Mage::helper('webforms')->__('Results / Notifications')
// ));
// $fieldset->addField('result_display', 'select', array(
// 'label' => Mage::helper('webforms')->__('Display field'),
// 'title' => Mage::helper('webforms')->__('Display field'),
// 'name' => 'result_display',
// 'note' => Mage::helper('webforms')->__('Display field in result / notification messages'),
// 'values' => Mage::getModel('webforms/fields_display')->toOptionArray(),
// ));
Mage::dispatchEvent('webforms_adminhtml_fields_edit_tab_design_prepare_form', array('form' => $form, 'fieldset' => $fieldset));
if (Mage::getSingleton('adminhtml/session')->getWebFormsData()) {
$form->setValues(Mage::getSingleton('adminhtml/session')->getWebFormsData());
Mage::getSingleton('adminhtml/session')->setWebFormsData(null);
} elseif (Mage::registry('field')) {
$form->setValues(Mage::registry('field')->getData());
}
return parent::_prepareForm();
}
示例13: getTitleHtml
public function getTitleHtml()
{
$form = new Varien_Data_Form();
$form->setDataObject($this->getProduct());
$title = $form->addField('downloads_title', 'text', array('label' => $this->_getHelper()->__('Title'), 'title' => $this->_getHelper()->__('Title'), 'name' => 'product[downloads_title]', 'value' => $this->getProduct()->getDownloadsTitle()));
$title->setEntityAttribute($this->getProduct()->getResource()->getAttribute('downloads_title'));
$title->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_form_renderer_fieldset_element'));
return $title->toHtml();
}
示例14: _prepareForm
protected function _prepareForm()
{
if ($group = $this->getGroup()) {
$form = new Varien_Data_Form();
/**
* Initialize product object as form property
* for using it in elements generation
*/
$form->setDataObject(Mage::registry('product'));
$fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('Mage_Catalog_Helper_Data')->__($group->getAttributeGroupName()), 'class' => 'fieldset-wide'));
$attributes = $this->getGroupAttributes();
$this->_setFieldset($attributes, $fieldset, array('gallery'));
if ($urlKey = $form->getElement('url_key')) {
$urlKey->setRenderer($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Form_Renderer_Attribute_Urlkey'));
}
if ($tierPrice = $form->getElement('tier_price')) {
$tierPrice->setRenderer($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier'));
}
if ($recurringProfile = $form->getElement('recurring_profile')) {
$recurringProfile->setRenderer($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Recurring'));
}
/**
* Add new attribute button if not image tab
*/
if (!$form->getElement('media_gallery') && Mage::getSingleton('Mage_Admin_Model_Session')->isAllowed('catalog/attributes/attributes')) {
$headerBar = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create');
$headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
$fieldset->setHeaderBar($headerBar->toHtml());
}
if ($form->getElement('meta_description')) {
$form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
}
$values = Mage::registry('product')->getData();
/**
* Set attribute default values for new product
*/
if (!Mage::registry('product')->getId()) {
foreach ($attributes as $attribute) {
if (!isset($values[$attribute->getAttributeCode()])) {
$values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
}
}
}
if (Mage::registry('product')->hasLockedAttributes()) {
foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
if ($element = $form->getElement($attribute)) {
$element->setReadonly(true, true);
}
}
}
$form->addValues($values);
$form->setFieldNameSuffix('product');
Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
$this->setForm($form);
}
}
示例15: testIsVirtualUnchecked
/**
* @param string $type
* @dataProvider physicalTypesDataProvider
*/
public function testIsVirtualUnchecked($type)
{
$currentProduct = Mage::getModel('Mage_Catalog_Model_Product');
$currentProduct->setTypeInstance(Mage::getObjectManager()->create($type));
$block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer();
$form = new Varien_Data_Form();
$form->setDataObject($currentProduct);
$block->setForm($form);
$this->assertNotContains('checked="checked"', $block->getElementHtml(), 'Is Virtual checkbox is selected for physical products');
}