php - cakephp habtm relationship (saving data) -


The questions related to HABTm have been posted to the stack overflow, but I still find the solution to my problem I am here. / P>

I am creating an application that allows for the creation of topics based on a particular subcategory. When adding a topic, the user is asked for the tag (on the same form) Now when the user has added the tags in the subject, clicking on the add button has successfully added the subject but have no tags.

I have both the subject and tags for tbl_tags_topics (as defined in the KPPP conventions) and both models of themes and tags have properly defined the 'The Andalong Tomami' array.

What action am I taking?

I have another question related to this but I will post it when I will send a database related to a subject successfully. (Functionality is similar to linking and enclosing Stoxhofflow tags)

Any help is greatly appreciated. If you have found anyone, then tell me about any good tutorials on HABT.

Thanks

When you save a field, Pass the parameters:

  $ this-> Model- & gt; Save ('model' = & gt; array ('id' => 1, 'name' = & gt; a random field));  

If you have tags that are an HABTM, then you can do the following:

  $ this-> Model- & gt; Save ('Model' = & gt; array ('id' => 1, 'name' = & gt; 'a random field'), 'tag' => array ('tag' = & gt; Array (1)));  

Although there is a problem with this basic feature, it is every time that you save your object, you must give the each tag to the saved array .

However, you can find in a bakery, which is called a plug-in.

By using it, you will:

  $ this-> Model- & gt; HabtmAdd ('tag', 1, 1);  

Where the first "1" model has the object ID and the second tag has the object ID.

To remove more tags:

  $ this-> Post- & gt; HabtmDelete ('tag', 1, 1);  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -