I am using Laravel BackPack Pro and I can't get full modal form for inline-create relation... It was working early, but after some coding and updates I found that this feature dosen't work any more with no any errors =\
My main model is Image, which has Tags (many-to-many) and Category (belongs-to) related models
Category inline-create still working! But tags - not.
I have no any errors, but the response of modal request - returns with only initial form, buttons and with NO any fields:
Common tag create action is Ok, and I did't rewrite any modal views.
Can someone explain what can be wrong?
Ok, I got it!
My setup tag crud controller was
public function setup() {
...
$this->crud->operation(['create', 'update'], function () {
...
}
}
But when I exclude create operation to separate method
protected function setupCreateOperation() {
...
}
all started working as expected!
Related
On user-registration confirmation I want to show a simple popup. For the moment, in order to simplify I'm happy to show an "Hello World".
This is the template file, views/templates/hook/registrationConfirm.tpl
<div id="idname" class="block">
<h1 class="title_block">HelloWorld</h1>
</div>
In my custom module I have this hook (which I know is being triggered doing debug):
public function hookActionCustomerAccountAdd($params) {
return $this->display(__FILE__, 'registrationConfirm.tpl');
}
It doesn't show anything (I also tried inspect the source code of the rendered page, but I dind't find the "HelloWorld")
Hooks starting by "Action" react to an action but do not display anything, but those starting with "Display" do.
You should also react to the hook displayCustomerAccount
public function hookActionCustomerAccountAdd() {
$this->is_new_account = true;
}
public function hookDisplayCustomerAccount()
{
if ($this->is_new_account) {
return $this->display(__FILE__, 'registrationConfirm.tpl');
}
}
I tried the solution posted by #shagshag but for some reason it doesn't work for me. So I share my solution (it's not pretty, nor efficient I think, but it seem to work for me): in the hookActionCustomerAccountAdd I save on a custom table (newCustomersTmp) email and customer id, because these are the data I need after, in the display Hook. Then in the hookDisplayCustomerAccount I check if an user with the current email ($this->context->customer->email) already exists in my table: if so I retrieve the data, do the actions I need with them and delete the row in the table.
Here is my code:
// <Name>test</Name>
warnif count > 0
let controllerType= ThirdParty.Types.WithFullName("System.Web.Mvc.Controller").Single()
from m in controllerType.Methods
select m
But I could only see these methods in Controller:
But clearly View is a method of Controller yet NDepend doesn't see it. Can any body point out what I am missing? Thanks.
[Update]
My original intent was to categorize actions according to the actual type of content they return (eg. html, fileresult, ajax result, etc) in my ASP.NET MVC code. To determine if an action returns html, I need to check if the action actually returns a ViewResult, including actions like the following which has a return type of ActionResult but actually returns ViewResult using the View method.
So I wanted to check if an action actually IsUsingMethod(mvcViewMethod) and as long as it calls any of the View method, I will consider this action as returning html. But now i couldn't get a reference to the mvcViewMethod.
[Update 2]
As suggested by Patrick, I checked out the class browser and only see this:
I don't see any View methods. This is much less than what I see in ILSpy of the same dll, where I can see the View method clearly defined:
And for an action like this:
In the class browser, if I right click this action and choose "Select methods that I use (Directly or Indirectly)", I will see this query result:
I still couldn't see it uses the View method.
[Final Update]
Following Patrick's suggestion, I added System.Web.Mvc dll into my application code dlls and it works perfectly now:
Using the infos in this link:
https://docs.typo3.org/typo3cms/ExtbaseFluidBook/8-Fluid/9-using-php-based-views.html
I try to create an action to output a JSON.
I have a normal controller with the list action:
public function listAction()
{
$storelocators = $this->storelocatorRepository->findAll();
$this->view->assign('storelocators', $storelocators);
}
And in ext/my_storelocator/Classes/View/Storelocator I have a class List.php:
<?
class Tx_MyStorelocator_View_Storelocator_List extends Tx_Extbase_MVC_View_AbstractView {
public function render() {
return 'Hello World';
}
}
All I get is:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "list" in class "My\MyStorelocator\Controller\StorelocatorController".
So I guess there is something wrong with the paths. Or where is the Problem?
Edit: Extensioninfos
Vendor: My
key: my_storelocator
controller: NOT SURE (I created it with the extension_builder so I guess my controllers name is Storelocator)
action: list
From my understanding a classname like Tx_MyStorelocator_View_Storelocator_List should be correct. But its not working
You will need to create an empty file for the HTML view for your controller, e.g. Resources/Private/Template/Storelocator/List.html, even if you do not plan to use the HTML view or if you just return the content yourself (which is perfectly fine).
The reason for this is simply technical limitation.
First of all, TYPO3 now has a built-in JSON view, described thoroughly here: https://usetypo3.com/json-view.html. It lets you easily define which properties you'd like to render.
The error message means that your Controller is still pointing to the TemplateView - because thats the error the TemplateView throws if it can't find the defined template file.
You can specify which view to use to render within your controller. You can either set a default view via the $defaultViewObjectName property, like so:
/**
* #var string
*/
protected $defaultViewObjectName = '\TYPO3\CMS\Fluid\View\TemplateView';
You can also set it from within the Controller inside initialization actions like so:
public function initializeExportPDFAction(){
$this->defaultViewObjectName = 'Vendor\Extension\View\FileTransferView';
}
(I have, however, not yet found a way to define the template from within actions, any tips in the comments would be appreciated)
Your path syntax is probably out of date. Instead of writing a render() function in Classes/View/Storelocator/List.php, try writing a listAction() function in a Classes/Controller/StorelocatorController.php file. Extension Builder should have created this file for you, if you made an aggregate model with the usual "list, create, edit ..." and such actions.
Review A journey through the Blog Example and the following chapter, Creating a first extension, for tips.
Keep in mind that there is a mismatch between the documentation and the Extension Builder generated PHP code files. Developing TYPO3 Extensions with Extbase and Fluid has some parts up to date, and other parts still using old syntax.
I'm using the October CMS and I'm having some trouble with deferred bindings.
I have two tables: products and product_images. I've split up my backend form into two tabs, one for product details and one for the product images:
I have my relationships set up correctly and use the following code (placed in a partial) to render the product images list:
<?= $this->relationRender('product_images'); ?>
The images tab looks like this:
The problem happens when I try to create a new image. When saving the image from the image modal, I get this exception:
I understand why there would be a constraint violation: The main record hasn't been saved yet, so there's no id for the image record to reference. In other words, the product image can't be associated with the product because the product doesn't exist yet.
The OctoberCMS documentation on deferred binding hints at a solution. But the documentation also states,
Deferred bindings are supported in the back-end Form behavior
automatically
Indeed, I haven't explicitly written any back-end form processing code. So even if I wanted to follow the instructions on deferred bindings, I wouldn't know where to put it. Any suggestions?
UPDATE:
In my config_relations.yaml file, I've set deferredBinding to true, but it made no difference:
product_images:
label: Image
deferredBinding: true
My products controller looks like:
class Products extends \Backend\Classes\Controller
{
public $implement = [
'Backend.Behaviors.FormController',
'Backend.Behaviors.ListController',
'Backend.Behaviors.RelationController'
];
public $formConfig = 'config_form.yaml';
public $listConfig = 'config_list.yaml';
public $relationConfig = 'config_relation.yaml';
public function __construct()
{
parent::__construct();
BackendMenu::setContext('MyPlugin.Products', 'products');
}
public function index()
{
$this->makeLists();
$this->makeView('index');
}
I do not have a product_images controller. I'm not sure why. Is that the issue?
My mistake was that I had put constraints on the product_id column in the product_images table:
$table->integer('product_id')->unsigned();
$table->foreign('product_id')->references('id')->on('me_myplugin_products');
Apparently I need to allow that column to be null. Changing it to this worked:
$table->integer('product_id')->nullable();
i have a complex form. This form is created in the controller A.
All actions, like: edit, add, load, index
are in the controller A defined and the method actionIndex is essential for all other requests.
Like this schema:
public class controllerA {
function actionIndex(Requerst r){
r.handleRequest();
if ($form->get('index')->isClicked()){
// Index Action
}
if ($form->get('add')->isClicked()){
$this->actionAdd();
}
// ...
}
function actionAdd(){}
}
}
How do i seperate the requests in different controllers?
Actually it doesnt feel good.
Here my actual code of the controller:
http://pastebin.com/HuXhV37q
I have skimmed through your code and I speak german so I understand it.
It would be too much to cover here so I just give you some "keywords".
Outsource business logic from controllers to symfony services to keep the controllers light. ($zusaetzeArray etc.)
Create Entities and FormTypes for the form data if it makes sense economically.
Create multiple controller actions with corresponding routes for the different form states.
Symfony2 Service: https://stackoverflow.com/a/13099900/982075