hook_action_info does not create its VBO list item in view - drupal-7

I am trying to code my custom action using views and VBO.
The my view shows the user a list of commerce line items.
Here the code:
function nlmcode_action_info() {
return array(
'vbo_download_pdf' => array(
'type' => 'entity',
'label' => t('Download PDF'),
'configurable' => FALSE,
'triggers' => array('any')
),
);
}
function vbo_download_pdf($entity, $context) {
dpm("Do the magic here.");
}
I then can see the bulk operation available in the select field but once I have selected my custom 'Download PDF' option and added to the view, the item is missing in the VBO drop down list.

Solved.
Permissions to 'Download PDF' have to be set.

Related

sonata_type_model_list how to delete image after select

Is it possible to delete a media after you have selected it (also in database)?
Many-to-One or One-to-One relations with sonata_type_model_list
->add('client', 'sonata_type_model_list', [
'btn_add' => $this->trans('admin.button.add_client'),
'btn_list' => $this->trans('admin.button.list'),
'btn_delete' => 'Delete button',
'btn_catalogue' => $this->translationDomain,
'label' => $this->trans('admin.label.client'),
'required' => true,
], [
'placeholder' => $this->trans('admin.placeholder.no_client'),
])
The line 'btn_delete' => 'delete button' gives you delete button
right of you one-to-one entity.
In this example I use an entity ClientCard which has one-to-one relation to Client entity.
List view.
By default you have delete button in list view.
Delete - is one of the batch actions. If you want to disable this action (and all other as well) you have to overwrite getBatchActions method
/**
* #return null
*/
public function getBatchActions()
{
return null;
}
Edit mode.
By default you have delete button in edit mode.
If you want completely disable the delete action, then you can overwrite configureRoutes method:
/**
* #param RouteCollection $collection
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('delete');
}
Hope it will help.

Cakephp3 Saving Multiple dropdown selections to database

I have a form with a dropdown that is multiple => true
echo $this - > Form - > input('test_id', [
'options' => $tests,
'required' => true,
'empty' => 'Select Tests',
'multiple' => true
]);
But when i submit the form only one value is saved in database.
I have searched for solution and found this:
Multiple select in input Cakephp
It suggests using SaveMany in my Controller, but i can't figure it out how to use it to get my desired output.
I'm very new to this framework so any help would be appreciated.
sorry i m also new but as other answers and question i don't see 'selected' => $selected in your form
CakePHP 2.0 Select form Mulitple selected
and How to set selection in mulitiselect list box in cakephp

cakephp 3 bootstrap-ui change prev/next text

I have FriendsofCake Bootstrap-ui plugin. I see in the source that it accepts text for the pagination prev and next labels.
I am not sure how to exactly set the config option though.
PaginatorHelper.php
if (isset($options['next'])) {
if ($options['next'] === true) {
$options['next'] = $this->config('labels.next');
}
$options['after'] = $this->next($options['next'], ['escape' => false]) . $options['after'];
}
I was trying this below in the bootstrap.php but no effect
Configure::write('friendsofcake.PaginatorHelper.labels.prev', 'previous');
But I see they are also set in the __construct
Answer
With the help from drmonkeyninja here is the exact code needed to configure the labels in the AppView.php
$this->loadHelper(
'Paginator',
[
'className' => 'BootstrapUI.Paginator',
'labels' => [
'prev' => 'previous',
'next' => 'next',
]
]
);
This appears to be badly documented, but to configure any of the settings for a helper you need to pass them as an array when you load it. So for example, if you are loading the Paginator helper inside your AppView you would pass prevlike this:-
$this->loadHelper(
'Paginator',
[
'className' => 'BootstrapUI.Paginator',
'prev' => 'previous'
]
);

How to use empty and selected in same dropdown box in cake php

I'm editing a dropdown box. i need to use empty and selected in same dropdown.
here is my code
$this->Form->input('per', array('id'=>'per','class'=>'inputs con_field','label'=>'per :', 'type'=>'select','options'=>$per_values,'selected'=>$labrcfps['Labourcfps']['per'],'empty'=>'- - Select --'));
If i use empty it automatically takes the empty as selected value.
I'm new in cakephp but i do this with array and parameter defaults :)
like that:
$options = array(
'x' => 'Select',
1 => 'Something',
2 => 'Car',
3 => 'Train'
);
echo $this->Form->input('name', array(
'options' => $options,
'default' => 'x'
));
Maybe that will be working fine :)
Variable $options is just your options after that you can validate if name of that field has value integer or 'x'. If 'x' then deny rest of logical code

Checkbox filtering in Magento admin grid

I have a Slider model having some associated Images (models). When editing a Slider, there's a tab for its images. Now this can be modified, to select and deselect containing images. This, it seems, is done through an admin grid, having a checkbox column (the "values" key is for testing):
$this->addColumn('in_slider', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_slider',
'values' => array(1,2),
'align' => 'center',
'index' => 'slider_image_id'
));
Let's say the Slider in the above image has one image attached, and that works fine. But, when user selects "Any" and clicks "Search", all images must show, but those that are not associated should be deselected. I think this is standard behavior for such a feature.
What I don't get is the mechanism behind those two buttons: Reset Filter and Search. From what I've managed to dig up, a grid class has a getGridUrl() method which is used to refresh the grid data (via AJAX). That URL mapping to a controller.
// in grid class
public function getGridUrl()
{
return $this->getUrl('*/*/editGrid', array('_current' => true));
}
// Image controller
public function editGridAction()
{
$blockMarkup = $this->getLayout()->createBlock('module/someblock')->toHtml();
$this->getResponse()->setBody($blockMarkup);
}
But what about the "Search" button? How does that work?
How do other modules know when to show ALL entities, or searching for "Yes" or "No"?
When saving the slider, how can one grab the selected values? Working in Slider controller's saveAction I presume, but how do you get the checkbox values?
What you're looking for is a mass action. Add this function to your grid file (whatever extends Mage_Adminhtml_Block_Weidget_Grid):
protected function _prepareMassaction()
{
$this->setMassactionIdField('some_ID');
$this->getMassactionBlock()->setFormFieldName('element_name'); //html name of checkbox
$this->getMassactionBlock()->addItem('some_ID', array(
'label'=> __('Some Label'),
'url' => $this->getUrl('*/*/doSomething'), //an action defined in the controller
'selected' => 'selected',
'confirm' => __('Are you sure?')
));
return $this;
}
Here's a good blog post that helps to explain the concept:
http://inchoo.net/ecommerce/magento/how-to-add-massactions-to-magentos-grid/

Resources