Add input field in Magento Admin Panel - magento

How can I add an <input type ="text"/> field in below screen shot of Magento Admin Panel to receive a value??
Thanks

Suppose you want to add "Title field".
You have to add following code on this file i.e. Am/Blog/Block/Adminhtml/Blog/Edit/Tab/Form.php
$fieldset->addField('title', 'text', array(
'label' => Mage::helper('blog')->__('Title'),
'class' => 'required-entry',
'required' => true,
'name' => 'title',
));

Related

Is there any way to display only info on update screen?

Here is my update / edit screen on customers area Backpack's admin panel.
ID's field type like text but it just disabled and readonly.
But when i try to save changes, it doesn't work. I think its my primary column and can't changable.
$fields =
[
[ 'name' => 'id', 'label' => 'ID', 'type' => 'text', 'hint' => __('dashboard.crud_listing.customers.hint_of_id'), 'attributes' => ['disabled' => 'disabled', 'readonly' => 'readonly'], 'fake' => true],
];
$this->crud->addFields($fields);
Can anyone have any idea about displaying some data, without saving on this ?
why you setting 'readonly' => 'readonly' inside the 'attributes':
like in doc:
you should set as like:
[ // Text
'name' => 'id',
'label' => "ID",
'type' => 'text',
'readonly' => 'readonly',
],

How to increase text area size of summnote field in laravel backpack

I am using laravel backpack as a crud and i'm creating a laravel admin panel with it. I need to use the summernote wysiwyg field and there is a options field attribute with laravel backpack and I am trying to input the minheight option for summer note however it does not add it to the intiatlaztion properly
$this->crud->addField([
'name' => 'desc',
'type' => 'summernote',
'label' => "feature description",
'options' => [
'minheight: 300'
]
]);
as you can see it does not increase the mineheight does anyone have any ideas?
i have a work around but it requires me to edit vendor files which it not something i want to have to deal with.
Place this script below your page to modify size and other characteristics of summernote editor:
<script type="text/javascript">
$(document).ready(function() {
$('#summernote').summernote({
height: 250,
disableResizeEditor: true // This is optional if you want to remove resize
});
});
</script>
Place your rows and cols size in the attributes array !
$this->crud->addField([
'name' => 'desc',
'type' => 'textarea',
'label' => "feature description",
'attributes' => [
'rows' => 20,
'cols' => 20
]
]);
You wrote your options property wrong.
'options' => [
'minheight: 300'
]
While actually it should be:
'options' => [
'minheight' => 300
]
See the difference?
You can use summernote API like this:
$this->crud->addField([
'name' => 'desc',
'type' => 'summernote',
'label' => "feature description",
'options' => [
'minheight' => 300,
'height' => 400
]
]);
$this->crud->addField([
// Summernote
'name' => 'description',
'label' => 'Описание',
'type' => 'summernote',
'options' => [
'placeholder'=> 'Содержание статьи',
'height'=> 500,
'toolbar'=>[
['style', ['style']],
['font', ['bold']], // show only bold button
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['fullscreen', 'codeview', 'help']]
],
]
]);

How to add a button in admin form?

I have add a button within admin form as follows.
$fieldset->addField('registered', 'button', array(
'label' => Mage::helper('core')->__('Send e-mail to all registered customers'),
'value' => Mage::helper('core')->__('Button Caption'),
'name' => 'registered',
'onclick' => "setLocation('{$this->getUrl('*/*/registeremail')}')",
));
The functionality of this field working properly but the button does not appear properly. It appears as follows.
How to appear this button as normal magento button?
I have tried with
'after_element_html' => '<button type="button" onclick="setLocation('{$this->getUrl('*/*/registeremail')}')">All Registered</button>'
But onclick call is wrong.
Try
$fieldset->addField('registered', 'button', array(
'label' => Mage::helper('core')->__('Send e-mail to all registered customers'),
'value' => Mage::helper('core')->__('Button Caption'),
'name' => 'registered',
'class' => 'form-button',
'onclick' => "setLocation('{$this->getUrl('*/*/registeremail')}')",
));
This works for me.

How can I add custom dropdown product attribute with options and their positions programmatically?

Like in subject I would like to add custom dropdown product attribute with options and their positions programmatically so I will be able to achieve list like in attached image.
You can use like following in your installer script.
$installer->addAttribute('catalog_product', "shirt_size", array(
'type' => 'int',
'input' => 'select',
'label' => 'Size',
'source' => '',
'sort_order' => 1000,
'required' => false,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'backend' => 'eav/entity_attribute_backend_array',
'option' => array (
'values' => array(
0 => 'Small',
1 => 'Medium',
2 => 'Large',
)
),
));

How to change comments data with onchange function in addfield in magento

I created custom module and now from admin side on edit form i added extra field select type.
I want to change comments with onchange function for this specific field.See below my code.
$eventElem = $fieldset->addField('banner_type', 'select', array(
'label' => Mage::helper('multibanners')->__('Banner Style'),
'required' => false,
'onchange' => 'checkSelectedItem(this.value)',
'name' => 'banner_type',
'values' => array(
array(
'value' => 'Banner 1',
'label' => 'AnySlider',
),
array(
'value' => 'Banner 2',
'label' => 'Content Slider',
),
));
$eventElem->setAfterElementHtml("<script type=\"text/javascript\">function checkSelectedItem(selectElement){}</script>");
This is my code i alert the value and i got my value but it cannot show it in comments area .Did someone one know how to fix it ?
Thanks
This will update the comment (onchange) with the current selected option
$fieldset->addField('banner_type', 'select', array(
'label' => Mage::helper('multibanners')->__('Banner Style'),
'required' => false,
'onchange' => 'checkSelectedItem(this.value)',
'name' => 'banner_type',
'values' => array(
array(
'value' => 'Banner 1',
'label' => 'AnySlider',
),
array(
'value' => 'Banner 2',
'label' => 'Content Slider',
),
)
))->setAfterElementHtml("<small id='banner_type_comment'>Comments</small>
<script type=\"text/javascript\">
function checkSelectedItem(selectElement){
$('banner_type_comment').update($('banner_type')[$('banner_type').selectedIndex].text);
}
</script>");

Resources