Sunday, July 13, 2014

Re: CakePHP 2.5, HABTM save data combining selected data and from multiple inputs

Mails like these end up in SPAM on Gmail. Use text instead or HTML , you will probably get more replies

T


On Fri, Jul 11, 2014 at 9:37 PM, Salines <nikola.paradzik@gmail.com> wrote:

I have habtm relationship between articles and tags. This works correctly.

Now in my Articles/admin_add.ctp want beside multiple selection inputs, add fields to add additional tags, and save it all together.

  echo $this->Form->input('Tag'); // multiple select  echo $this->Form->input('Tag.0.name'); // add new tag  echo $this->Form->input('Tag.1.name'); // add new tag

in my ArticlesController::admin_add i have:

  ... $this->Article->saveAll($this->request->data, array('deep' => true)) ..

debug submitet data:

  debug($this->request->data);  array(  'Article' => array(      'title' => 'Test title',      'user_id' => '1',       ....  ),  'Tag' => array(      'Tag' => array(          (int) 0 => '2', // selected data          (int) 1 => '3'  // selected data      ),      (int) 0 => array(          'name' => 'Wine' // new data      ),      (int) 1 => array(          'name' => 'Icecreme' // new data      )  ),

The aim is to save the new tags and make their association when saving a new article. What is the correct way to save this query?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
=============================================================
The Conference Schedule Creator : http://shdlr.com

PHP for E-Biz : http://sanisoft.com
=============================================================

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: