本文整理汇总了PHP中Magento\Backend\Block\Widget\Form\Generic::_prepareLayout方法的典型用法代码示例。如果您正苦于以下问题:PHP Generic::_prepareLayout方法的具体用法?PHP Generic::_prepareLayout怎么用?PHP Generic::_prepareLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\Block\Widget\Form\Generic
的用法示例。
在下文中一共展示了Generic::_prepareLayout方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareLayout
/**
* Prepare form for render
*
* @return void
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$demoId = $this->_coreRegistry->registry('current_demo_id');
/** @var \Genmato\Sample\Model\DemoFactory $demoData */
if ($demoId === null) {
$demoData = $this->demoDataFactory->create();
} else {
$demoData = $this->demoDataFactory->create()->load($demoId);
}
$yesNo = [];
$yesNo[0] = 'No';
$yesNo[1] = 'Yes';
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Basic Information')]);
$fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Title'), 'title' => __('Title'), 'required' => true]);
$fieldset->addField('is_active', 'select', ['name' => 'is_active', 'label' => __('Active'), 'title' => __('Active'), 'class' => 'required-entry', 'required' => true, 'values' => $yesNo]);
$fieldset->addField('is_visible', 'select', ['name' => 'is_visible', 'label' => __('Visible'), 'title' => __('Visible'), 'class' => 'required-entry', 'required' => true, 'values' => $yesNo]);
if ($demoData->getId() !== null) {
// If edit add id
$form->addField('demo_id', 'hidden', ['name' => 'demo_id', 'value' => $demoData->getId()]);
}
if ($this->_backendSession->getDemoData()) {
$form->addValues($this->_backendSession->getDemoData());
$this->_backendSession->setDemoData(null);
} else {
$form->addValues(['id' => $demoData->getId(), 'title' => $demoData->getTitle(), 'is_active' => $demoData->getIsActive(), 'is_visible' => $demoData->getIsVisible()]);
}
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('*/*/save'));
$form->setMethod('post');
$this->setForm($form);
}
示例2: _prepareLayout
/**
* Load Wysiwyg on demand and Prepare layout
*
* @return void
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
if ($this->_wysiwygConfig->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
}
}
示例3: _prepareLayout
/**
* Prepare layout.
* Add files to use dialog windows
*
* @return $this
*/
protected function _prepareLayout()
{
if ($head = $this->getLayout()->getBlock('head')) {
$head->addChild('prototype-window-js', 'Magento\\Theme\\Block\\Html\\Head\\Script', array('file' => 'prototype/window.js'));
$head->addChild('prototype-windows-themes-default-css', 'Magento\\Theme\\Block\\Html\\Head\\Css', array('file' => 'prototype/windows/themes/default.css'));
$head->addChild('magento-core-prototype-magento-css', 'Magento\\Theme\\Block\\Html\\Head\\Css', array('file' => 'Magento_Core::prototype/magento.css'));
}
return parent::_prepareLayout();
}
示例4: _prepareLayout
/**
* Prepare form for render
*
* @return void
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getUrl('tbslider/*/save'), 'method' => 'post', 'enctype' => 'multipart/form-data']]);
$slideritemsId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_SLIDERITEM_ID);
/** @var \Stepzerosolutions\Tbslider\Api\Data\SlideritemsInterface $slideritem */
if ($slideritemsId === null) {
$slider = $this->slideritemsDataFactory->create();
} else {
$slider = $this->_slideritemsRepository->getById($slideritemsId);
}
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Slider item Information')]);
$validateClass = 'required-entry validate-length maximum-length-100';
$slideritemTitle = $fieldset->addField('slideritem_title', 'text', ['name' => 'slideritem_title', 'label' => __('Title'), 'title' => __('Title'), 'class' => $validateClass, 'required' => true]);
$fieldset->addField('slideritem_description', 'editor', ['name' => 'slideritem_description', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:25em', 'config' => $this->_wysiwygConfig->getConfig()]);
$fieldset->addField('slideritem_slider', 'select', ['name' => 'slideritem_slider', 'label' => __('Select Slider'), 'class' => 'required-entry', 'values' => $this->sliderSource->toOptionArray(), 'value' => isset($formValues['slideritem_slider']) ? $formValues['slideritem_slider'] : [], 'required' => true]);
$slideritemTitle = $fieldset->addField('slider_url', 'text', ['name' => 'slider_url', 'label' => __('URL'), 'title' => __('URL'), 'class' => '']);
$fieldset->addField('filename', 'image', ['title' => __('Slider Image'), 'label' => __('Slider Image'), 'name' => 'filename', 'note' => 'Allow image type: jpg, jpeg, gif, png', 'class' => 'required-entry', 'required' => true]);
$fieldset->addField('filenamemd', 'image', ['title' => __('Slider Image (Medium Devices). Leave empty for auto generate'), 'label' => __('Slider Image (Medium Devices). Leave empty for auto generate'), 'name' => 'filenamemd', 'note' => 'Allow image type: jpg, jpeg, gif, png']);
$fieldset->addField('filenamesm', 'image', ['title' => __('Slider Image (Small Devices). Leave empty for auto generate'), 'label' => __('Slider Image (Small Devices). Leave empty for auto generate'), 'name' => 'filenamesm', 'note' => 'Allow image type: jpg, jpeg, gif, png']);
$fieldset->addField('filenamexs', 'image', ['title' => __('Slider Image (Extra Small Devices). Leave empty for auto generate'), 'label' => __('Slider Image (Extra Small Devices). Leave empty for auto generate'), 'name' => 'filenamexs', 'note' => 'Allow image type: jpg, jpeg, gif, png']);
$fieldset->addField('is_active', 'select', ['label' => __('Is Active'), 'title' => __('Is Active'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]);
$slideritemTitle = $fieldset->addField('slider_sort', 'text', ['name' => 'slider_sort', 'label' => __('Sort Order'), 'title' => __('Sort Order'), 'class' => 'validate-length maximum-length-4', 'width' => '80px']);
//var_dump($slider->getData());
if ($slider->getId() !== null) {
// If edit add id
$form->addField('id', 'hidden', ['name' => 'id', 'value' => $slider->getId()]);
}
if ($this->_backendSession->getslideritemsData()) {
$form->addValues($this->_backendSession->getslideritemsData());
$this->_backendSession->setslideritemsData(null);
} else {
// TODO: need to figure out how the DATA can work with forms
$tmp = $slider->getSliderImagePath();
$filename = !empty($tmp) ? $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $slider->getSliderImagePath() : null;
$tmp = $slider->getSliderImageMdPath();
$filenamemd = !empty($tmp) ? $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $slider->getSliderImageMdPath() : null;
$tmp = $slider->getSliderImageSmPath();
$filenamesm = !empty($tmp) ? $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $slider->getSliderImageSmPath() : null;
$tmp = $slider->getSliderImageXsPath();
$filenamexs = !empty($tmp) ? $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $slider->getSliderImageXsPath() : null;
$form->addValues(['slideritem_id' => $slider->getId(), 'slideritem_title' => $slider->getSlideritemTitle(), 'slideritem_description' => $slider->getSlideritemDescription(), 'filename' => $filename, 'filenamemd' => $filenamemd, 'filenamesm' => $filenamesm, 'filenamexs' => $filenamexs, 'slideritem_slider' => $slider->getSlideritemSlider(), 'is_active' => $slider->getIsActive(), 'slider_sort' => $slider->getSliderSort()]);
}
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('tbslider/*/save'));
$form->setMethod('post');
$this->setForm($form);
}
示例5: _prepareLayout
/**
* Prepare form for render
*
* @return void
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
/** @var \Magento\Customer\Api\Data\GroupInterface $customerGroup */
if ($groupId === null) {
$customerGroup = $this->groupDataFactory->create();
$defaultCustomerTaxClass = $this->_taxHelper->getDefaultCustomerTaxClass();
} else {
$customerGroup = $this->_groupRepository->getById($groupId);
$defaultCustomerTaxClass = $customerGroup->getTaxClassId();
}
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Group Information')]);
$validateClass = sprintf('required-entry validate-length maximum-length-%d', \Magento\Customer\Model\GroupManagement::GROUP_CODE_MAX_LENGTH);
$name = $fieldset->addField('customer_group_code', 'text', ['name' => 'code', 'label' => __('Group Name'), 'title' => __('Group Name'), 'note' => __('Maximum length must be less then %1 symbols', \Magento\Customer\Model\GroupManagement::GROUP_CODE_MAX_LENGTH), 'class' => $validateClass, 'required' => true]);
if ($customerGroup->getId() == 0 && $customerGroup->getCode()) {
$name->setDisabled(true);
}
$fieldset->addField('tax_class_id', 'select', ['name' => 'tax_class', 'label' => __('Tax Class'), 'title' => __('Tax Class'), 'class' => 'required-entry', 'required' => true, 'values' => $this->_taxCustomer->toOptionArray()]);
if ($customerGroup->getId() !== null) {
// If edit add id
$form->addField('id', 'hidden', ['name' => 'id', 'value' => $customerGroup->getId()]);
}
if ($this->_backendSession->getCustomerGroupData()) {
$form->addValues($this->_backendSession->getCustomerGroupData());
$this->_backendSession->setCustomerGroupData(null);
} else {
// TODO: need to figure out how the DATA can work with forms
$form->addValues(['id' => $customerGroup->getId(), 'customer_group_code' => $customerGroup->getCode(), 'tax_class_id' => $defaultCustomerTaxClass]);
}
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('customer/*/save'));
$form->setMethod('post');
$this->setForm($form);
}
示例6: _prepareLayout
/**
* Prepare block children and data
*
* @return void
*/
protected function _prepareLayout()
{
$onclick = "jQuery('[data-form=edit-product]').attr('action', " . $this->_coreHelper->jsonEncode($this->getContinueUrl()) . ").addClass('ignore-validate').submit();";
$this->addChild('continue_button', 'Magento\\Backend\\Block\\Widget\\Button', ['label' => __('Generate Variations'), 'onclick' => $onclick, 'class' => 'save']);
parent::_prepareLayout();
}
示例7: _prepareLayout
/**
* Prepare the layout.
*
* @return $this
*/
protected function _prepareLayout()
{
$this->setChild('grid', $this->getLayout()->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Newsletter\\Grid', 'newsletter.grid'));
parent::_prepareLayout();
return $this;
}
示例8: _prepareLayout
/**
* Prepare layout.
* Add files to use dialog windows
*
* @return $this
*/
protected function _prepareLayout()
{
$this->pageConfig->addPageAsset('prototype/windows/themes/default.css');
return parent::_prepareLayout();
}
示例9: _prepareLayout
protected function _prepareLayout()
{
parent::_prepareLayout();
\Magento\Framework\Data\Form::setFieldsetElementRenderer($this->createBlock('Magento\\Form\\Renderer\\Element'));
\Magento\Framework\Data\Form::setFieldsetRenderer($this->createBlock('Magento\\Form\\Renderer\\Fieldset'));
}
示例10: _prepareLayout
/**
* Prepare form for render
*
* @return void
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$sliderId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_SLIDER_ID);
/** @var \Stepzerosolutions\Tbslider\Api\Data\sliderInterface $slider */
if ($sliderId === null) {
$slider = $this->sliderDataFactory->create();
} else {
$slider = $this->_sliderRepository->getById($sliderId);
}
// Get slider stores in an array, if not return null
$sliderstores = $this->_sliderRepository->getSliderStoreList($slider);
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Slider Information')]);
$validateClass = 'required-entry validate-length maximum-length-100';
$sliderTitle = $fieldset->addField('slider_title', 'text', ['name' => 'slider_title', 'label' => __('Title'), 'title' => __('Title'), 'class' => $validateClass, 'required' => true]);
$sliderDescription = $fieldset->addField('slider_description', 'textarea', ['name' => 'slider_description', 'label' => __('Description'), 'title' => __('Description'), 'class' => $validateClass, 'required' => true]);
/* Check is single store mode */
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true), 'value' => $sliderstores]);
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
$slider->setStoreId($this->_storeManager->getStore(true)->getId());
}
$tmpstatus = $slider->getStatus();
$fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')], 'value' => empty($tmpstatus) ? 0 : $slider->getStatus()]);
$responsiveFieldset = $form->addFieldset('responsive_fieldset', ['legend' => __('Responsive Information')]);
$dimentionClass = 'validate-length maximum-length-6';
$sliderWidth = $responsiveFieldset->addField('slider_width', 'text', ['name' => 'slider_width', 'label' => __('Width'), 'title' => __('Width'), 'class' => 'required-entry ' . $dimentionClass, 'note' => 'Add % sign for width in presentage', 'required' => true]);
$sliderHeight = $responsiveFieldset->addField('slider_height', 'text', ['name' => 'slider_height', 'label' => __('Height'), 'title' => __('Height'), 'note' => 'Insert "auto" to set auto height', 'class' => 'required-entry ' . $dimentionClass, 'required' => true]);
$slider_widthxs = $responsiveFieldset->addField('slider_widthxs', 'text', ['name' => 'slider_widthxs', 'label' => __('Mobile device width'), 'title' => __('Mobile device width'), 'class' => $dimentionClass]);
$slider_heighthxs = $responsiveFieldset->addField('slider_heighthxs', 'text', ['name' => 'slider_heighthxs', 'label' => __('Mobile device height'), 'title' => __('Mobile device height'), 'class' => $dimentionClass]);
$slider_widthsm = $responsiveFieldset->addField('slider_widthsm', 'text', ['name' => 'slider_widthsm', 'label' => __('Small device width'), 'title' => __('Small device width'), 'class' => $dimentionClass]);
$slider_heightsm = $responsiveFieldset->addField('slider_heightsm', 'text', ['name' => 'slider_heightsm', 'label' => __('Small device height'), 'title' => __('Small device height'), 'class' => $dimentionClass]);
$slider_widthmd = $responsiveFieldset->addField('slider_widthmd', 'text', ['name' => 'slider_widthmd', 'label' => __('Medium device width'), 'title' => __('Medium device width'), 'class' => $dimentionClass]);
$slider_heightmd = $responsiveFieldset->addField('slider_heightmd', 'text', ['name' => 'slider_heightmd', 'label' => __('Medium device height'), 'title' => __('Medium device height'), 'class' => $dimentionClass]);
$designFieldset = $form->addFieldset('design_fieldset', ['legend' => __('Design Information')]);
$designClass = 'validate-length maximum-length-7';
$slider_class = $designFieldset->addField('slider_class', 'text', ['name' => 'slider_class', 'label' => __('CSS Class'), 'title' => __('CSS Class'), 'class' => $dimentionClass]);
$slider_bgcolor = $designFieldset->addField('slider_bgcolor', 'text', ['name' => 'slider_bgcolor', 'label' => __('Background Color'), 'title' => __('Background Color'), 'class' => $designClass]);
$slider_autoresoponsive = $designFieldset->addField('slider_autoresoponsive', 'text', ['name' => 'slider_autoresoponsive', 'label' => __('Auto Responsive'), 'title' => __('Auto Responsive'), 'class' => '']);
$tmpSliderType = $slider->getSliderType();
$slider_type = $designFieldset->addField('slider_type', 'select', ['name' => 'slider_type', 'label' => __('Slider Type'), 'title' => __('Slider Type'), 'class' => '', 'options' => $this->_sliderHelper->getSliderTypeName(), 'value' => empty($tmpSliderType) ? 0 : $slider->getSliderType()]);
$getPauseonhover = $slider->getPauseonhover();
$pauseonhover = $designFieldset->addField('pauseonhover', 'select', ['name' => 'pauseonhover', 'label' => __('Pause on hover'), 'title' => __('Pause on hover'), 'class' => '', 'options' => ['1' => __('Enabled'), '0' => __('Disabled')], 'value' => empty($getPauseonhover) ? 0 : $slider->getPauseonhover()]);
$getWrap = $slider->getWrap();
$wrap = $designFieldset->addField('wrap', 'select', ['name' => 'wrap', 'label' => __('Wrap'), 'title' => __('Wrap'), 'class' => '', 'options' => ['1' => __('Enabled'), '0' => __('Disabled')], 'value' => empty($getWrap) ? 0 : $slider->getWrap()]);
$getKeyboard = $slider->getKeyboard();
$keyboard = $designFieldset->addField('keyboard', 'select', ['name' => 'keyboard', 'label' => __('Keyboard'), 'title' => __('Keyboard'), 'class' => '', 'options' => ['1' => __('Enabled'), '0' => __('Disabled')], 'value' => empty($getKeyboard) ? 0 : $slider->getKeyboard()]);
$slidermeta = $designFieldset->addField('slidermeta', 'text', ['name' => 'slidermeta', 'label' => __('Slider Meta'), 'title' => __('Slider Meta'), 'class' => '']);
$getSliderHidexs = $slider->getSliderHidexs();
$hidexs = $designFieldset->addField('slider_hidexs', 'select', ['name' => 'slider_hidexs', 'label' => __('Hide On Mobile Devices'), 'title' => __('Hide On Mobile Devices'), 'class' => '', 'options' => ['1' => __('Enabled'), '0' => __('Disabled')], 'value' => empty($getSliderHidexs) ? 0 : $slider->getSliderHidexs()]);
$getSliderDuration = $slider->getSliderDuration();
$duration = $designFieldset->addField('slider_duration', 'select', ['name' => 'slider_duration', 'label' => __('Slider Durations'), 'title' => __('Slider Duration'), 'class' => '', 'options' => ['500' => __('500'), '1000' => __('1000'), '2000' => __('2000'), '4000' => __('4000'), '5000' => __('5000'), '6000' => __('6000'), '7000' => __('7000'), '8000' => __('8000'), '9000' => __('9000'), '10000' => __('10000'), '15000' => __('15000'), '20000' => __('20000')], 'value' => empty($getSliderDuration) ? 500 : $slider->getSliderDuration()]);
$getHidenavigation = $slider->getHidenavigation();
$hidexs = $designFieldset->addField('hidenavigation', 'select', ['name' => 'hidenavigation', 'label' => __('Hide Navigation Controls'), 'title' => __('Hide Navigation Controls'), 'class' => '', 'options' => ['1' => __('Yes'), '0' => __('No')], 'value' => empty($getHidenavigation) ? 0 : $slider->getHidenavigation()]);
if (!$slider->getId()) {
$slider->setData('status', '0');
}
//var_dump($slider->getData());
if ($slider->getId() !== null) {
// If edit add id
$form->addField('id', 'hidden', ['name' => 'id', 'value' => $slider->getId()]);
}
if ($this->_backendSession->getsliderData()) {
$form->addValues($this->_backendSession->getsliderData());
$this->_backendSession->setsliderData(null);
} else {
// TODO: need to figure out how the DATA can work with forms
$form->addValues(['slider_id' => $slider->getId(), 'slider_title' => $slider->getSliderTitle(), 'slider_description' => $slider->getSliderDescription(), 'slider_width' => $slider->getSliderWidth(), 'slider_height' => $slider->getSliderHeight()]);
}
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('tbslider/*/save'));
$form->setMethod('post');
$this->setForm($form);
}