contao/import — Issue #2436: Allow Ajax call of DC_Table
Author: Toflar
Created: 2011-11-29 19:33:56+00:00
State: open
Labels: backend, Feature

Hi Leo

Right now I'm developing a widget that allows the user to edit a foreign DCA.
In fact it is going to be part of Isotope and the example why this is needed is the following:
Right now every product has its price - one price only.
Now I have a customer that needs different prices for the same product, depending on things like the usergroup or special prices during Christmas or whatever.

So I thought the easiest way for the user would be a widget within tl_iso_products where he or she can edit the table tl_iso_prices via Ajax.
Obviously I could call my php methods using the existing "executePostActions" hook and copy the parts of DC_Table I need.

Instead of copying all this code I thought it's easier if I just call the normal edit mode (e.g. main.php?do=dcaWizard&table=tl_iso_prices&act=edit&id=1) and inject what I need in my widget which works like a charm.

Now I get to the problem. When submitting the form with the same action (so still main.php?do=dcaWizard&table=tl_iso_prices&act=edit&id=1) the data is stored correctly in the database BUT I get forwarded, because you reload the page after saving to prevent POST data from being sent twice, which is perfectly correct.
But my ajax call doesn't get any result because of the hard reload and I'd like to parse the response for

's so the validation doesn't get lost.

In fact I just need you to change line 1741 in DC_Table (rev 525) from the following code:

```
if ($this->Input->post('FORM_SUBMIT') == $this->strTable &&

![]($this->noReload)
```

into this:

```
if ($this->Input->post('FORM_SUBMIT') == $this->strTable && )$this->noReload && !$this->Input->get('isAjax'))
```

This way I can request the data like this: main.php?do=dcaWizard&table=tl_iso_prices&act=edit&id=1&isAjax=1
I don't get forwarded and get the data I need.

A very small change and tested :-)

Thanks for reading and implementing ;-)
Yanick

--- _Originally created on August 14th, 2010, at 04:38pm (ID 2436)_