Call custom functions in laravel backpack - laravel-backpack

I want to create a button next to each row in the Laravel Backpack list view to call a function that generates an excel (or print a PDF, or whatever). This function is in a helpers class that I have created. I don't see a way to do this, it seems that I can only create buttons that call functions within the model, isn't there a way to be able to call functions within a controller or within a class? I don't want to create certain functions within the model

Related

AnyLogic - create objects dynamically on simulation time

Is it possible to dynamically create objects or modify them on run-time ?for example,on button click,another button created or change number of lines of a road?
When I write this code for a button Action,in run-time
road123.setBackwardLanesCount(3);
I get error below:
root:
road123: Markup element is already initiated and cannot be modified.Please use constructor without arguments,perform setup and finally call initialize() .function
You'll get that error with any object you attempt to create at runtime using a parameterized constructor. If you create the object with a simple constructor (just "()") and then set all of the parameters individually, you won't run into that issue. Check the Anylogic API for specific information about the object you are using, because some require you to call .initiliaze() on that object after setting all of it's parameters if you created it using a simple constructor. Furthermore, if you want to add the object to the screen at runtime you'll need to add this code to the function that creates it:
#Override
public void onDraw( Panel panel, Graphics2D graphics) {
obj.drawModel(panel, graphics, true);
}
where obj is replaced with the name of the object you created dynamically.

How to define own functions in zend framework

Actually I wanted to know that is there any way to define and call a function in Zend framework which does not need to put with $this like pr() function in cake php. I want to define a such a function which can be called directly in all controllers and views in zend framework. Can it be done by putting all functions in helper and use them without writing $this in front of them.
For example I wanted to make a function arrprint() to print the array in helper and use it globally with only by writing simply arrprint();
Please help me
You could just create a file anywhere and put the function in there. The just include it like you would any other files.
Or create a library called Utils and put your custom functions there as static and call them using:
Utils::myFunction();
Contrary to cake zf does not enforce much anything. You can leverage the framework to do whatever you want.
BTW $this is just a pointer to the current class and when you use $this->myFunction(); it's because that function is a member of the current class (or its parent).

Passing parameters in mvp pattern

This might be a general mvp places and activities question, but the show case I'm trying to understand here is this gwtphonegap-showcase-gwt example.
How do I pass a parameter to a view from another one?
For example, let's say I want that when a user clicks on any cell on the OverviewActivity, it will take them to the same place everytime (AboutPlace), but the text should be different (let's say it contains the cell number).
I added a setText(String text) to the AboutDisplay interface with the corresponding label and setText() in the AboutDisplayGwtImpl, but I have no idea where to call it. I tried calling it in AboutActivity start() method and ClientFactoryGwtImpl getAboutDisplay() method, but they seem to be called only once when the app first loads, so I end up with the same text each time.
you should not use a view directly for that.
You can add a field on a place and set your value there and access the same value in the next activity.

How to create instance to zend controller

I have a controller named class TestController which extends some Zend_Controller_Action. Now I would like to use create an instance of TestController in TestForms (a Zend_Form). I want to populate a Zend_Form_Element_Select dynamically.
Please suggest how I can do this. Thanx in advance.
Where are you instantiating the form - is it in the controller? Instead of having the form call an action on the controller to dynamically get the values, you should look at setting the values on the form after it has been instantiated.
A quick and dirty way of doing that would be to grab the values in the controller and assign it to the element via:
$values = $db->query('query');
$element = $form->getElement('dynamicSelect');
$element->setValue($values);
Of course having DB queries to a table in your controller isn't exactly best practice... Per philistyne's suggestion, I use a a form builder class to build forms dynamically from my models. I have mappers for each model, and I pass in the mapper to the form builder class so it can dynamically populate my select elements.
A couple of things to try (passing a controller into a form or instantiating from within one is not recommended):
Use a model to access the dynamic values you want to put into your Zend_Form_Element_Select.
If the form is complex, create a form builder class to take care of, and separate out, the heavy lifting of the form construction.
Create customised form elements by extending from Zend_Form_Element_(Radio, Select, etc etc) if you feel you need very fine control over the form element's construction/behaviour/appearance, but wish to be able to reuse that element elsewhere.

Zend Framework - Using custom functions in Forms

I have MyForm extending Zend_Form, with init() doing regular job.
In this init() I also need to use a function to apply some transformation on some element values. Basically, get values from db -> custom transformation function -> apply them to form element.
I can put this custom function inside the form itself, but it's a general one and it will be reused by other forms.
Question: what is the best way to do this? I'm reading that helpers are associated more with views, and plugins with controllers. Is there a nice and easy way to get in the form the functionality of a custom function?
(something as helpers in symfony - just a bunch of functions)
Thanks.
p.s. this custom function is not a validator or so.