<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Forum CakePHP.org.pl - Problem z przechwytywaniem danych]]></title>
		<link>http://forum.cakephp.org.pl/topic/24/problem-z-przechwytywaniem-danych/</link>
		<description><![CDATA[Najświeższe odpowiedzi w Problem z przechwytywaniem danych.]]></description>
		<lastBuildDate>Mon, 24 Nov 2008 21:21:28 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Odp: Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/70/#p70</link>
			<description><![CDATA[<p>Dobrym rozwiązaniem na problemy z cache&#039;owaniem w trakcie pisania aplikacji jest ustawienie zmiennej debug na 2 lub 3 w pliku app/config/core.php</p><p>Wtedy nie trzeba manualnie usuwać cache po każdej zmianie w widokach i dodatkowo wyświetla się fajne podsumowanie sql&#039;owych kwerend <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (darek_dobron)]]></author>
			<pubDate>Mon, 24 Nov 2008 21:21:28 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/70/#p70</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/69/#p69</link>
			<description><![CDATA[<p>udało się, działa <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Problem został usunięty w momencie usunięcia cache-a modelu POst <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Fallen)]]></author>
			<pubDate>Mon, 24 Nov 2008 11:57:19 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/69/#p69</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/68/#p68</link>
			<description><![CDATA[<p>Dzięki <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /><br />Ale niestety napotkałem kolejny problem <img src="http://forum.cakephp.org.pl/img/smilies/hmm.png" width="15" height="15" alt="hmm" /></p><p>Mam coś takiego:<br /></p><div class="codebox"><pre><code>&lt;div class=&quot;posts form&quot;&gt;
&lt;form id=&quot;PostAddForm&quot; method=&quot;post&quot; action=&quot;/cake/posts/add&quot;&gt;
&lt;fieldset style=&quot;display:none;&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;POST&quot; /&gt;&lt;/fieldset&gt;&lt;fieldset&gt;
&lt;legend&gt;New Post&lt;/legend&gt;
&lt;input type=&quot;hidden&quot; name=&quot;data[Post][id]&quot; value=&quot;&quot; id=&quot;PostId&quot; /&gt;
&lt;label for=&quot;PostTitle&quot;&gt;Title&lt;/label&gt;&lt;input name=&quot;data[Post][title]&quot; type=&quot;text&quot; length=&quot;120&quot; value=&quot;&quot; id=&quot;PostTitle&quot; /&gt;&lt;br&gt;
&lt;label for=&quot;PostBody&quot;&gt;Body&lt;/label&gt;&lt;textarea name=&quot;data[Post][body]&quot; cols=&quot;30&quot; rows=&quot;6&quot; id=&quot;PostBody&quot; &gt;&lt;/textarea&gt;&lt;br&gt;
&lt;label for=&quot;PostAutor&quot;&gt;Autor&lt;/label&gt;&lt;input name=&quot;data[Post][autor]&quot; type=&quot;text&quot; length=&quot;120&quot; value=&quot;&quot; id=&quot;PostAutor&quot; /&gt;
&lt;/fieldset&gt;
&lt;div class=&quot;submit&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</code></pre></div><p>Wszystko sie ładnie dodaje prócz&nbsp; data[Post][autor], why?<br />Dodałem dodatkowe pole w tabeli <img src="http://forum.cakephp.org.pl/img/smilies/hmm.png" width="15" height="15" alt="hmm" /><br />Podobna sytuacja jest w druga stronę kiedy nawet dodam ręcznie autora, cake nie chce szczytywać go z bazy:/<br /></p><div class="codebox"><pre><code>&lt;?php foreach ($data as $post): ?&gt;
echo $post[&#039;Post&#039;][&#039;title&#039;]; - działa
echo $post[&#039;Post&#039;][&#039;body&#039;]; - działa
echo $post[&#039;Post&#039;][&#039;created&#039;]; - działa
echo $post[&#039;Post&#039;][&#039;autor&#039;]; - nie działa</code></pre></div><p>Czy wina może sie brać z faktu że pole autor dołączyłem po pewnym czasie a wcześniej all działało bez tego pola?</p>]]></description>
			<author><![CDATA[dummy@example.com (Fallen)]]></author>
			<pubDate>Mon, 24 Nov 2008 10:18:19 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/68/#p68</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/67/#p67</link>
			<description><![CDATA[<div class="quotebox"><cite>Fallen napisał/a:</cite><blockquote><p>dzięki działa <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Teraz staram sie zrobić logowanie <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p></blockquote></div><p>Jeśli chcesz coś prostego to polecam <a href="http://bakery.cakephp.org/articles/view/simple-form-authentication-in-1-2-x-x">http://bakery.cakephp.org/articles/view &#133; in-1-2-x-x</a></p>]]></description>
			<author><![CDATA[dummy@example.com (darek_dobron)]]></author>
			<pubDate>Mon, 24 Nov 2008 07:41:55 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/67/#p67</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/66/#p66</link>
			<description><![CDATA[<p>dzięki działa <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Teraz staram sie zrobić logowanie <img src="http://forum.cakephp.org.pl/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Fallen)]]></author>
			<pubDate>Sun, 23 Nov 2008 21:52:54 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/66/#p66</guid>
		</item>
		<item>
			<title><![CDATA[Odp: Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/65/#p65</link>
			<description><![CDATA[<p>Rozwiązaniem może być wstawienie id posta przed save&#039;m, tak aby funkcja miała postać:</p><div class="codebox"><pre><code>function add($post_id) {

$this-&gt;set(&#039;post_id&#039;,$post_id);

if (!empty($this-&gt;data)) {
          $this-&gt;data[&#039;Comment&#039;][&#039;post_id&#039;]=$post_id;
            if ($this-&gt;Comment-&gt;save($this-&gt;data)) {
                $this-&gt;flash(&#039;Your Comment has been saved.&#039;, &#039;/posts&#039;);
            }
        }
 }</code></pre></div><p>Wtedy konieczne jeszcze jest dodanie numeru posta w akcji formularza (wcześniej trzeba tą wartość przekazać w kontrolerze):<br />Pola CommentId i PostId będą w tym wypadku w formularzxu zbędne, ponieważ PostId wypełniane jest przed dodaniem komentarza natomiast CommentId powstaje dopiero po wstawieniu komentarza do bazy. Formularz miałby więc postać zbliżoną do:</p><div class="codebox"><pre><code>&lt;div class=&quot;comment form&quot;&gt;
&lt;form id=&quot;CommentAddForm&quot; method=&quot;post&quot; action=&quot;/cake/app/webroot/index.php/comments/add/&lt;?php echo $post_id; ?&gt;&quot;&gt;
&lt;fieldset style=&quot;display:none;&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;POST&quot; /&gt;&lt;/fieldset&gt;&lt;fieldset&gt;&lt;legend&gt;New Comment&lt;/legend&gt;
&lt;div class=&quot;input text&quot;&gt;&lt;label for=&quot;CommentAuthor&quot;&gt;Author&lt;/label&gt;
&lt;input name=&quot;data[Comment][author]&quot; type=&quot;text&quot; maxlength=&quot;50&quot; value=&quot;&quot; id=&quot;CommentAuthor&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;input textarea&quot;&gt;&lt;label for=&quot;CommentBody&quot;&gt;Body&lt;/label&gt;&lt;textarea name=&quot;data[Comment][body]&quot; cols=&quot;30&quot; rows=&quot;6&quot; id=&quot;CommentBody&quot; &gt;&lt;/textarea&gt;
&lt;/div&gt;&lt;/fieldset&gt;&lt;div class=&quot;submit&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</code></pre></div><p>Niestety przy dodawaniu posta użytkownik będzie mógł wpisać w adres przeglądarki dowolny numer po comments/add/ i potrzebna będzie dobra walidacja. Drugie możliwe rozwiązanie to użycie sesji do przekazania wartości zmiennej post_id.</p>]]></description>
			<author><![CDATA[dummy@example.com (darek_dobron)]]></author>
			<pubDate>Sun, 23 Nov 2008 20:30:22 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/65/#p65</guid>
		</item>
		<item>
			<title><![CDATA[Problem z przechwytywaniem danych]]></title>
			<link>http://forum.cakephp.org.pl/post/64/#p64</link>
			<description><![CDATA[<p>Mam problem z przechwytywaniem danych <img src="http://forum.cakephp.org.pl/img/smilies/sad.png" width="15" height="15" alt="sad" /></p><p>Sytuacja wygląda następująco mam link który prowadzi do formularze z dodawaniem komentarza:</p><div class="codebox"><pre><code>&lt;?php echo $html-&gt;link(&#039;Dodaj Komentarz&#039;,
 &#039;/comments/add/&#039;.$data[&#039;Post&#039;][&#039;id&#039;]); ?&gt;</code></pre></div><p>Oraz funkcje która służy do dodawania do bazy komentarza:</p><div class="codebox"><pre><code>function add($post_id) {

if (!empty($this-&gt;data)) {
            if ($this-&gt;Comment-&gt;save($this-&gt;data)) {
                $this-&gt;flash(&#039;Your Comment has been saved.&#039;, &#039;/posts&#039;);
            }
        }
 }</code></pre></div><p>Czy aby funkcja add przechwyciła $data[&#039;Post&#039;][&#039;id&#039;],<br />wystarczy&nbsp; $this-&gt;Post-&gt;setPost_id($post_id), a jeżeli tak to w którym miejscu trzeba ją wstawić ?(kiedy wstawiam ją na początku funkcji nie działam, tak samo w warunku)</p><p>Czy trzeba to rozwiązać inaczej?<br />Tak aby pole Post_id w zapisywanym komentarzu miało wartość&nbsp; &nbsp;$data[&#039;Post&#039;][&#039;id&#039;] ??</p><p>Kod formularza dodającego komentarz:</p><div class="codebox"><pre><code>&lt;div class=&quot;comment form&quot;&gt;
&lt;form id=&quot;CommentAddForm&quot; method=&quot;post&quot; action=&quot;/cake/app/webroot/index.php/comments/add&quot;&gt;
&lt;fieldset style=&quot;display:none;&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;POST&quot; /&gt;&lt;/fieldset&gt;&lt;fieldset&gt;&lt;legend&gt;New Comment&lt;/legend&gt;
&lt;input type=&quot;hidden&quot; name=&quot;data[Comment][id]&quot; value=&quot;&quot; id=&quot;CommentId&quot; /&gt;&lt;div class=&quot;input select&quot;&gt;&lt;label for=&quot;CommentPostId&quot;&gt;Post&lt;/label&gt;&lt;input type=&quot;hidden&quot; name=&quot;data[Comment][post_id]&quot; value=&quot;&quot; id=&quot;CommentPostId&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;input text&quot;&gt;&lt;label for=&quot;CommentAuthor&quot;&gt;Author&lt;/label&gt;
&lt;input name=&quot;data[Comment][author]&quot; type=&quot;text&quot; maxlength=&quot;50&quot; value=&quot;&quot; id=&quot;CommentAuthor&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;input textarea&quot;&gt;&lt;label for=&quot;CommentBody&quot;&gt;Body&lt;/label&gt;&lt;textarea name=&quot;data[Comment][body]&quot; cols=&quot;30&quot; rows=&quot;6&quot; id=&quot;CommentBody&quot; &gt;&lt;/textarea&gt;
&lt;/div&gt;&lt;/fieldset&gt;&lt;div class=&quot;submit&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (Fallen)]]></author>
			<pubDate>Sun, 23 Nov 2008 11:02:37 +0000</pubDate>
			<guid>http://forum.cakephp.org.pl/post/64/#p64</guid>
		</item>
	</channel>
</rss>
