How do you load a custom element action using getAvailableActions inside my Element Type class?
public function getAvailableActions($source = null)
{
$customAction = craft()->elements->getAction('Custom');
$customAction->setParams(array(
'label' => Craft::t('Custom'),
));
$actions[] = $customAction;
}
The above renders a PHP error PHP Fatal error: Call to a member function setParams() on a non-object
PluginName_CustomElementAction is my file inside the elementactions folder, inside my plugin. Which is copied directly from https://craftcms.com/docs/plugins/element-actions
Here's what it looks like:
namespace Craft;
class PluginName_CustomElementAction extends BaseElementAction
{
public function getName()
{
return Craft::t('Custom');
}
public function isDestructive()
{
return true;
}
public function performAction(ElementCriteriaModel $criteria)
{
// Remove all the ingredients from the selected elements
$elements = $criteria->find();
foreach ($elements as $element)
{
craft()->cocktailRecipes->removeAllIngredientsFromElement($element);
}
// Success!
$this->setMessage(Craft::t('Ingredients removed successfully.'));
return true;
}
}
What is wrong with my getAvailableActions object?
getAvailableActions
method? It'd probably help to share what's in your main element class as well.