本文整理汇总了PHP中Varien_Data_Form_Element_Fieldset::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Fieldset::getId方法的具体用法?PHP Varien_Data_Form_Element_Fieldset::getId怎么用?PHP Varien_Data_Form_Element_Fieldset::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Data_Form_Element_Fieldset
的用法示例。
在下文中一共展示了Varien_Data_Form_Element_Fieldset::getId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addRendererField
/**
* Add field to form based on parameter configuration
*
* @param Varien_Data_Form_Element_Fieldset $fieldset
* @param Varien_Object $parameter
* @return Varien_Data_Form_Element_Abstract
*/
protected function _addRendererField($fieldset, $parameter)
{
$form = $this->getForm();
// Prepare element data with values (either from request of from default values)
$fieldName = $parameter->getKey();
$data = array('name' => $form->addSuffixToName($fieldName, 'parameters'), 'label' => $this->_translationHelper->__($parameter->getLabel()), 'required' => $parameter->getRequired(), 'class' => 'renderer-option', 'note' => $this->_translationHelper->__($parameter->getDescription()));
if ($values = $this->getRendererParams()) {
$data['value'] = isset($values[$fieldName]) ? $values[$fieldName] : '';
} else {
$data['value'] = $parameter->getValue();
// Prepare unique ID value
if ($fieldName == 'unique_id' && $data['value'] == '') {
$data['value'] = md5(microtime(1));
}
}
// Prepare element dropdown values
if ($values = $parameter->getValues()) {
// Dropdown options are specified in configuration
$data['values'] = array();
foreach ($values as $option) {
$data['values'][] = array('label' => $this->_translationHelper->__($option['label']), 'value' => $option['value']);
}
} elseif ($sourceModel = $parameter->getSourceModel()) {
// Otherwise, a source model is specified
if (is_array($sourceModel)) {
// TODO check if invalid model / method ?
$data['values'] = call_user_func(array(Mage::getModel($sourceModel['model']), $sourceModel['method']));
} else {
$data['values'] = Mage::getModel($sourceModel)->toOptionArray();
}
}
// Prepare field type or renderer
$fieldRenderer = null;
$fieldType = $parameter->getType();
if (!$parameter->getVisible()) {
// Hidden element
$fieldType = 'hidden';
} elseif (false !== strpos($fieldType, '/')) {
// Just an element renderer
$fieldRenderer = $this->getLayout()->createBlock($fieldType);
$fieldType = $this->_defaultElementType;
}
// Instantiate field and render html
$field = $fieldset->addField($this->getFieldsetHtmlId() . '_' . $fieldName, $fieldType, $data);
if ($fieldRenderer) {
$field->setRenderer($fieldRenderer);
}
// Extra html preparations
if ($helper = $parameter->getHelperBlock()) {
$helperBlock = $this->getLayout()->createBlock($helper->getType(), '', $helper->getData());
if ($helperBlock instanceof Varien_Object) {
$helperBlock->setConfig($helper->getData())->setFieldsetId($fieldset->getId())->setTranslationHelper($this->_translationHelper)->prepareElementHtml($field);
}
}
// Dependencies from other fields
$dependenceBlock = $this->getChild('form_after');
$dependenceBlock->addFieldMap($field->getId(), $fieldName);
if ($parameter->getDepends()) {
foreach ($parameter->getDepends() as $from => $row) {
$values = isset($row['values']) ? array_values($row['values']) : (string) $row['value'];
$dependenceBlock->addFieldDependence($fieldName, $from, $values);
}
}
return $field;
}