Problem with form content plugin in detail page

Hi,

The form content plugin is returning an error "SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data" when I use it on a detail page.
This form is used as a content menu. The user chooses a content title and is redirected to the page (plz see PHP below for better understanding).
This form just has 2 fields : id and dbjoin.
The form has a PHP plugin redirecting the user when he chooses a page. Here is the PHP I use :
PHP:
$db = JFactory::getDbo();
$projet_id = $db->Quote('{fk_projets_recherche___projets_raw}');
if($projet_id!="''"){
$query = "SELECT id, url, itemid_pays FROM jos2_projet WHERE id=$projet_id";
$db->setQuery($query);
$result = $db->loadObject();
$link = "index.php?option=com_fabrik&view=details&formid=5&rowid=".$result->id."-".$result->url."&Itemid=".$result->itemid_pays;
$msg='';
$app = JFactory::getApplication();
$app->redirect(JRoute::_($link,false), $msg, $msgType='message');}
The thing is that even if the form is set up to validate without AJAX, it seems to call ajax anyway...

I tried to use a form module instead of the content plugin, but the form module only works on lists. On detail pages, it grabs the detail page id and slug and add it the form id such as
HTML:
<form id="form_31_1:my-page-slug" class="fabrikForm" method="post" name="form_31" enctype="application/x-www-form-urlencoded">
... and then the js on the form isn't working (I trigger the form validation onchange on the dbjoin).

Using the the content plugin would be more flexible than the module, yet do you have an idea of the problem ?

Thanks for your help !
 
Last edited:
I added this site to mysites under "CB". You just have to click on the site url to see an example of the problem in the top of the right column.
Thanks !
 
OK, no, you can't do that. You can't "redirect" in response to an AJAX call. All that does is then return the entire page to the Javascript that calls the AJAX.

And yes, when you use a content plugin, we automatically do submission through AJAX.

I'm not entirely clear on what you are trying to do here. Are you trying to reload that module in place when the user chooses from the menu, or redirect to a new page?

-- hugh
 
Hi, and thanks for your answer,

Yes, I'd like to redirect to a new page :
1 - the user chooses a project title in the dbjoin (value = project row id) and triggers the form via js "onchange"
2 - the PHP form plugin gets url datas for the project and build the project url
3 - user is redirected to the selected project page
4 - the new page loads and I have the current project selected in the dbjoin

Content plugin seemed adapted to do this, but is it possible to validate the form content plugin through PHP instead of AJAX ?

The module could work, but the form is returning a bad id that prevents js from working.... and also, I don't know if it's possible to grab the current page id to set the dbjoin default value...

I changed the content plugin for a module on the page, so you can take a look.

Thanks for your help.
 
Can you explain how you are inserting a module into the detail view?

I would have a look, but I don't seem to be able to get in to the back end with the specified login.

-- hugh
 
Hi,
I use the {loadposition xxxx} method in the detail custom template called "projets". You can see the files in backend cause I installed extplorer.
Sorry for the logins, I now unlocked the dev superadmin account.
Thanks !
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top