Jump to content


set_relation_n_n gives me jQuery error, how to fix?

set_relation_n_n

  • Please log in to reply
3 replies to this topic

#1 kaosweaver

kaosweaver

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 20 August 2012 - 03:00 PM

Ok, so I've setup a news table and a hashtag table and a table between them (news, tags, news_x_tags).
I setup the news CRUD and it worked just fine:

$this->load->library('grocery_CRUD');
$crud = new grocery_CRUD();
		
$crud->set_table('news')
->set_subject('News')
->columns('news_title','news_content','news_publish_on','news_author')
->display_as('news_title','Title')
->display_as('news_content','Content')
->display_as('news_publish_on','Publish Date')
->display_as('news_author','Author');
		
$crud->order_by('news_publish_on','desc');

$crud->required_fields('news_title','event_tnews_contentype','news_publish_on','news_author');
		
$data['output'] = $crud->render();

When I add the following (under the ORDER BY line), it renders correctly:

$crud->set_relation_n_n('news','news_x_tags','tags','news_id','tag_id','tag_name','taggedby')
->display_as("news","Tags");

However, when I go to submit, I get:

Timestamp: 8/20/2012 9:53:04 AM
Error: SyntaxError: JSON.parse: unexpected character
Source File: http://myserver.com/assets/grocery_crud/js/jquery-1.7.1.min.js
Line: 2


What do I need to change in order to get this to function as expected? I appreciate your help.

#2 kaosweaver

kaosweaver

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 23 August 2012 - 01:05 PM

No ideas anyone?

#3 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 23 August 2012 - 03:20 PM

You have "news" as table name, and "news" as the first parameter of set_relation_n_n.
The set_relation_n_n require the first parameter to be field, not table
Can you try to use this:

$this->load->library('grocery_CRUD');
$crud = new grocery_CRUD();
			  
$crud->set_table('news')
	->set_subject('News')
	->columns('news_title','news_content','news_publish_on','news_author','x')
	->display_as('news_title','Title')
	->display_as('news_content','Content')
	->display_as('news_publish_on','Publish Date')
	->display_as('news_author','Author');

$crud->set_relation_n_n('x','news_x_tags','tags','news_id','tag_id','tag_name','taggedby')
	->display_as("x","Tags");
			  
$crud->order_by('news_publish_on','desc');
$crud->required_fields('news_title','event_tnews_contentype','news_publish_on','news_author');
			  
$data['output'] = $crud->render();

No-CMS homepage : http://www.getnocms.com
No-CMS forum : http://www.getnocms.com/forum
No-CMS Github page : https://github.com/g...diAsgard/No-CMS

 

Please don't mix up No-CMS and groceryCRUD issues.
(eg: user authentication etc is No-CMS specific issue and has nothing to do with groceryCRUD)

 


#4 kaosweaver

kaosweaver

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 27 August 2012 - 01:10 PM

Thanks for the tips, I figured it out by seeing the reply, apparently, the user for the DB I'd setup didn't have permissions on one of the tables, so when the update happened, it returned a mysql/php error and the code didn't report it back as an error. Changed the user to the right one with permissions and - wow - it worked! Again, thanks for the tips, I appreciate the help.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users