Disable row clicking action helperList Prestashop - prestashop-1.7

I have created a helperList and defined the rowActions using addRowAction view, edit and delete. Everything works fine but I have noticed that on clicking the row not the buttons, the action of the first rowAction button i.e. 'view' in this case is performed. How can I disable it such that only the button click performs the action while clicking anywhere else on the table i.e. on the rows does nothing. I am working on prestashop 1.7.

I searched for the issue and found the solution for that, Hope It will help you
If you want to remove the click you have to define it in your field list for each column with 'remove_onclick' => true,
$this->fields_list = [
'id' => [
'title' => $this->l('Id'),
'type' => 'text',
'align' => 'center',
'search' => false,
'remove_onclick' => true,
],
];
or $helper->no_link = true; in Helper Form
$helper = new HelperList();
$helper->no_link = true;

Try to add "$this->list_no_link = true;" in "__construct()" function.
public function __construct()
{
...
...
$this->list_no_link = true;
}

Related

Passing variable to the view from zend form using AJAX load

controller:
public function searchAction()
{
$form = new Application_Form_Search;
$k = $form->getValue('keyword');
$car = new Application_Model_Car();
$mapper = new Application_Model_CarMapper();
$this->view->cars = $mapper->search($keyword);
}
form
<?php
class Application_Form_Search extends Zend_Form {
public function init(){
$this->setMethod('post');
$this->addElement('text', 'keyword', array(
'required' => true,
'label' => 'Keyword:'
));
$this->addElement('button', 'submit', array(
'required' => false,
'ignore' => true,
'label' => 'Search'
));
}
}
?>
original view page
$(document).ready(function(){
$("#submit").click(function(){
$("#main").load('/cars/search');
});
});
Here I am trying to return the search view at the "id=main" section in the original view page by using .load()
In the search view, <?=$this->keyword?> is showing null
it seems like there's problem fetching the keyword field from the form
Ok, you need to set the second variable of .load to send the data. At present you aren't sending the data to the .load function
so it would be more like this. This is assuming that you have id of keyword
$("#main").load('/cars/search', {'keyword':$('input#keyword').val()});
or you could use
$("#main").load('/cars/search', {'keyword':$('[name="keyword"]').val()});
Please see
http://api.jquery.com/load/
Also remember to escape the value so people can't send malicious code through your form.
Hope that helps

Yii2 ajax update row status and hide row after status change

I am using Yii2 gridview with custom action button. On click custom button i want to update status of that record and hide that row from gridview.
Also want to show success message.
[
'class' => 'yii\grid\ActionColumn',
'header'=>'Actions',
'template' => '{confirm}',
'buttons' => [
//view button
'confirm' => function ($url, $model) {
return Html::a('Confirm', $url, [
'title' => Yii::t('app', 'Confirm Address'),
'class'=>'btn btn-success',
]);
},
],
'urlCreator' => function ($action, $model, $key, $index) {
if ($action === 'confirm') {
return Url::to(['customers/confirmaddress','id'=>$model->id]);
}
}
]
You can Pjax at beginning of GridView and configure dateProvider to show those value having status other than update Status value on confirm prompt an alert box and make your confirm button to data-pjax => true so handle pjax request and update your Pjax -container after ajax request is successfull .. provide some more extra controller code

Create menu item in joomla programmatically

I've created a Joomla 3 component that will add some menu items programmatically. I've searched how to do it and I found this old question/answer:
Programmatically Create Menu Item in Joomla
It suggest to use this code:
//add the article to a menu item
$menuTable = JTable::getInstance('Menu', 'JTable', array());
$menuData = array(
'menutype' => 'client-pages',
'title' => $data[name],
'type' => 'component',
'component_id' => 22,
'link' => 'index.php?option=com_content&view=article&id='.$resultID,
'language' => '*',
'published' => 1,
'parent_id' => '1',
'level' => 1,
);
// Bind data
if (!$menuTable->bind($menuData))
{
$this->setError($menuTable->getError());
return false;
}
// Check the data.
if (!$menuTable->check())
{
$this->setError($menuTable->getError());
return false;
}
// Store the data.
if (!$menuTable->store())
{
$this->setError($menuTable->getError());
return false;
}
It works but have the same problem as shown on the question I linked.
Showing the error: Warning: str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0 in .....
And someone suggest this solution I can't understand.
Try using JTableNested::setLocation($referenceId, $position = 'after'):
$table->setLocation($parent_id, 'last-child');
I also think that you need to rebuild the path:
// Rebuild the tree path.
if (!$table->rebuildPath($table->id)) {
$this->setError($table->getError());
return false;
}
Could someone explain me where to use that solution?

Not saving data when add multiple select attribute in product grid

I have created one custom module with add associated products concept. Created successfully. And Its working well.
But when i add "Multi select attribute" column in product grid with that option values, That entity value not saved.
If i removed that option values from that brand attribute drop down, Its saving fine.
I have shown my code below what i did for add multi select attribute column in product grid
under _prepareColumns() method
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'brand'); // attribute code here
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
{
if($option['value'] != '')
$valArr[$option['value']] = $option['label'];
}
$this->addColumn('brand', array(
'header'=> Mage::helper('catalog')->__('Brand'),
'align' => 'left',
'index' => 'brand',
'type' => 'options',
'options' => $valArr,
'renderer' => 'Mage_Adminhtml_Block_Catalog_Product_Renderer_Brands', // Will have to create the renderer.
'filter_condition_callback' => array($this, '_filterBrandCondition')
));
When i hide 'options' => $valArr, , All are working fine.
I can't able to understand, why its happening. Please suggest me your ideas. Thanks in advance.
Have you already created the _filterBrandCondition function ?
What Mage_Adminhtml_Block_Catalog_Product_Renderer_Brands look like ?

Problem when I am populating data into selectbox through ajax in Drupal

I have installed drupal 6, added some cck fields in one content type. Added two select box fields.
I am taking the selected value of parent select box and as per that selection passing relates options to next select box field using Ajax. (e.g Country -> State. When user selects country I want to pass state values into next select box.)
But when I am submitting the form it gives the following error:
"An illegal choice has been detected. Please contact the site administrator."
I don't know why it is not taking the ajaxified select box values while saving the node.
Does somebody has the solution on it. Is there any solution to handle this dynamic select options in Drupal.
Thanks in advance.
The same thing I'm working on drupal 7 and its work for me. Below is the code. Hope this help you. What I have done is on selection of car model car variant will change and the data save in the table.
function add_offer_form($form, $formstate) {
$form['add_offer_new_car_model'] = array(
'#type' => 'select',
'#required' => TRUE,
'#options' => $car_model,
'#ajax' => array(
'effect' => 'fade',
'progress' => array('type' => 'none'),
'callback' => 'variant_callback',
'wrapper' => 'replace_variant',
),
);
// Combo box to select new car variant
$form['add_offer_new_car_variant'] = array(
'#type' => 'select',
'#options' => array(),
// The prefix/suffix provide the div that we're replacing, named by #ajax['wrapper'] above.
'#prefix' => '<div id="replace_variant">',
'#suffix' => '</div>',
);
// An AJAX request calls the form builder function for every change.
// We can change how we build the form based on $form_state.
if (!empty($formstate['values']['add_offer_new_car_model'])) {
$model_id = $formstate['values']['add_offer_new_car_model'];
$rows = array();
$result = db_query("SELECT id, variant_name from {va_car_variant} where car_model_id in ($model_id,1) order by variant_name");
while ($data = $result->fetchObject()) {
$id = $data->id;
$rows[$id] = $data->variant_name;
}
$form['add_offer_new_car_variant']['#options'] = $rows;
}
}
////////////////////////////////////////////////////////
///////// FUNCTION FOR AJAX CALL BACK
function variant_callback($form, &$form_state) {
return $form['add_offer_new_car_variant'];
}

Resources