Re: adding additional jquery functionality on cake 1.3

2010-07-29 Thread Jon Chin
Thanks a bunch!  I read through the code snippet but haven't tried it yet.
 But I think this gives me a lot closer than anything else I've found on the
web.  I was hoping that there would be a way to utilize the Js helper rather
than output to $scripts_for_layout.  Thanks, though--this gives me a good
start!

On Fri, Jul 23, 2010 at 10:54 AM, cricket zijn.digi...@gmail.com wrote:

 On Fri, Jul 23, 2010 at 3:13 AM, Jon Chin port23u...@gmail.com wrote:
  I followed the tutorial for getting Jquery set up on Cake 1.3, but now
 I'm
  having trouble getting Jquery plugins to work.  I haven't been able to
 find
  any webpages or tutorials for this, so I'm asking here.  I think what I
 need
  to do is somehow get the code for the plugin to get added to the buffer
 and
  in the $(document).ready function.  Maybe extend the jquery_engine?  I'm
 not
  sure how to do it, so can anybody steer me in the right direction?
  Thanks!

 In what sense is it not working? When you view source, do you see
 script tags for the plugin(s)? If so, is the path correct? How are you
 trying to include them? In the layout? View? Show some code; perhaps
 you have an error there.

 As for adding things to $(document).ready() note that jquery can
 handle multiple calls to that. IOW, you can have a ready() block in
 your global.js, your admin.js, in one or more script blocks in the
 head, etc. So, let's say you want to add a WYSIWYG editor to some
 view. You can include the necessary plugin from the view as well as a
 JS block with the plugin's init code inside another call to
 $(document).ready().

 layout:
 echo $html-script('lib/jquery-1.4.1.min');
 echo $html-script('global');
 echo $scripts_for_layout;

 view:
 echo $this-element('wysiwyg', array('selectors' =
 array('#PageContent'), 'upload_path' = '/uploads'));

 element:
 $html-css('jwysiwyg/jquery.wysiwyg', 'stylesheet',
 array('media'='screen,projector', 'inline' = false));
 echo $html-script('lib/jquery.form.min', false);
 echo $html-script('lib/jquery.wysiwyg', false);
 echo $html-script('editor', false);

 $code = '$(function() { ';
 foreach($selectors as $selector)
 {
if (empty($upload_path)) $upload_path = null;
$code .= initEditor('${selector}', '${upload_path}');\n;
 }
 $code .= '});';
 $html-scriptBlock($code, array('inline' = false));

 The scriptBlock method will add a new call to ready() (I'm using a
 slightly different jquery syntax here) into $scripts_for_layout.

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


adding additional jquery functionality on cake 1.3

2010-07-23 Thread Jon Chin
I followed the tutorial for getting Jquery set up on Cake 1.3, but now I'm
having trouble getting Jquery plugins to work.  I haven't been able to find
any webpages or tutorials for this, so I'm asking here.  I think what I need
to do is somehow get the code for the plugin to get added to the buffer and
in the $(document).ready function.  Maybe extend the jquery_engine?  I'm not
sure how to do it, so can anybody steer me in the right direction?  Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How do I save a field on my User without breaking the ACL?

2010-05-24 Thread Jon Chin
I'm using Auth and db ACL, but I have an action that screws up my ACL
records every time.  I have ACL set up just like the Book instructs.  I'm
building a change password page where I want to just update the password.
 I run the following commands:
 $this-User-id = $this-Session-read('Auth.User.id');
$this-User-saveField('password', $this-data['User']['password']);
(I've also tried $this-User-save()).  When I execute this, it deletes the
user's parent_id from the aros table as well as corrupts the tree-ness of
the ACL tables.  What am I doing wrong?  Thanks in advance.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I save a field on my User without breaking the ACL?

2010-05-24 Thread Jon Chin
I tried that and have the same result.  Do I need to unbind a relationship
or something?

On Mon, May 24, 2010 at 2:06 PM, Filipe Teles Rodrigues 
filipe.t2...@gmail.com wrote:

 I use $this-User-save($this-data) instead of saveField.

 2010/5/24 Jon Chin port23u...@gmail.com

 I'm using Auth and db ACL, but I have an action that screws up my ACL
 records every time.  I have ACL set up just like the Book instructs.  I'm
 building a change password page where I want to just update the password.
  I run the following commands:
  $this-User-id = $this-Session-read('Auth.User.id');
 $this-User-saveField('password', $this-data['User']['password']);
 (I've also tried $this-User-save()).  When I execute this, it deletes
 the user's parent_id from the aros table as well as corrupts the tree-ness
 of the ACL tables.  What am I doing wrong?  Thanks in advance.

 Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


  Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I get Acl working?

2010-04-29 Thread Jon Chin
Thanks for the suggestions.  It turned out that I needed to add
$this-Auth-Authorize = 'actions'; to my AppController.

On Wed, Apr 28, 2010 at 11:26 PM, Andrei Mita andrei.m...@gmail.com wrote:

 Try running the build_acl and initDB actions again. Or check in your tables
 if you have the restrictions set.



 On Thu, Apr 29, 2010 at 8:03 AM, Jon Chin port23u...@gmail.com wrote:

 I just did a global search and I don't have that anywhere.  Maybe I did
 something wrong in my AppController?

 class AppController extends Controller {
 var $components = array('Acl', 'Auth', 'Session');
  function beforeFilter() {
 $this-Auth-fields = array(
  'username' = 'email',
 'password' = 'password'
  );
 $this-Auth-loginAction = array('controller' = 'users', 'action' =
 'login');
  $this-Auth-logoutRedirect = array('controller' = 'users', 'action' =
 'login');
 $this-Auth-loginRedirect = array('controller' = 'projects', 'action' =
 'index');
  $this-Auth-actionPath = 'controllers/';
 }
 }

 On Wed, Apr 28, 2010 at 8:44 PM, Matthew Powell php...@gmail.com wrote:

 Did you perhaps leave a $this-Auth-allow('*'); in there somewhere?

 Matt

 On Wed, Apr 28, 2010 at 21:33, Jon Chin port23u...@gmail.com wrote:
  I'm having a bit of a problem getting Auth+ACL working.  I've followed
 the
  Simple Acl Controlled Application example in the Cake book. It
 is correctly
  locking out unauthenticated users from the system.  However, all
  authenticated users are able to access all ACOs in my site, even if the
  group they belong to is denied access.  I've been at it for hours, but
 can't
  seem to figure out what I'm doing wrong.  Any ideas?
 
  Check out the new CakePHP Questions site http://cakeqs.org and help
 others
  with their CakePHP related questions.
 
  You received this message because you are subscribed to the Google
 Groups
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
   more options, visit this group at
  http://groups.google.com/group/cake-php?hl=en
 

 Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


  Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


  Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How do I get Acl working?

2010-04-28 Thread Jon Chin
I'm having a bit of a problem getting Auth+ACL working.  I've followed the
Simple Acl Controlled Application example in the Cake book. It *is* correctly
locking out unauthenticated users from the system.  However, all
authenticated users are able to access all ACOs in my site, even if the
group they belong to is denied access.  I've been at it for hours, but can't
seem to figure out what I'm doing wrong.  Any ideas?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: How do I get Acl working?

2010-04-28 Thread Jon Chin
I just did a global search and I don't have that anywhere.  Maybe I did
something wrong in my AppController?

class AppController extends Controller {
var $components = array('Acl', 'Auth', 'Session');
 function beforeFilter() {
$this-Auth-fields = array(
 'username' = 'email',
'password' = 'password'
 );
$this-Auth-loginAction = array('controller' = 'users', 'action' =
'login');
 $this-Auth-logoutRedirect = array('controller' = 'users', 'action' =
'login');
$this-Auth-loginRedirect = array('controller' = 'projects', 'action' =
'index');
 $this-Auth-actionPath = 'controllers/';
}
}

On Wed, Apr 28, 2010 at 8:44 PM, Matthew Powell php...@gmail.com wrote:

 Did you perhaps leave a $this-Auth-allow('*'); in there somewhere?

 Matt

 On Wed, Apr 28, 2010 at 21:33, Jon Chin port23u...@gmail.com wrote:
  I'm having a bit of a problem getting Auth+ACL working.  I've followed
 the
  Simple Acl Controlled Application example in the Cake book. It
 is correctly
  locking out unauthenticated users from the system.  However, all
  authenticated users are able to access all ACOs in my site, even if the
  group they belong to is denied access.  I've been at it for hours, but
 can't
  seem to figure out what I'm doing wrong.  Any ideas?
 
  Check out the new CakePHP Questions site http://cakeqs.org and help
 others
  with their CakePHP related questions.
 
  You received this message because you are subscribed to the Google Groups
  CakePHP group.
  To post to this group, send email to cake-php@googlegroups.com
  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
   more options, visit this group at
  http://groups.google.com/group/cake-php?hl=en
 

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


problem with saveAll

2009-07-16 Thread Jon Chin
I'm experiencing weird behavior with using $this-model-saveAll().  
When I pass it an array of just one record, it successfully inserts this 
to the db table.  However, when I pass it an array of more than one 
record, they all successfully insert except for the last record.  
Anybody have an idea of what could be wrong?  Thanks.


--
Jon Chin




smime.p7s
Description: S/MIME Cryptographic Signature


Re: problem with saveAll

2009-07-16 Thread Jon Chin
Seems like it's working now.  I changed the table type to MyISAM, which 
corrupted the table.  So I repaired it and changed it back to InnoDB.  
Now it's working fine.  I didn't change any code.  Can anybody explain this?


Jon Chin




Jon Chin wrote:
I'm experiencing weird behavior with using $this-model-saveAll().  
When I pass it an array of just one record, it successfully inserts 
this to the db table.  However, when I pass it an array of more than 
one record, they all successfully insert except for the last record.  
Anybody have an idea of what could be wrong?  Thanks.




smime.p7s
Description: S/MIME Cryptographic Signature


Re: A Search Behavior

2009-07-11 Thread Jon Chin
I'm actually in the process of implementing Sphinx in my website.  I've 
investigated several other search indexing tools (Lucene, Xapian, etc), 
and Sphinx seems to give the most bang for your effort.  There was a 
Sphinx Behavior in the bakery, but as of today, it says that it's been 
taken down until it can be approved for publication.  If you google 
sphinx behavior cakephp you can get a cached version of the page.

Jon Chin




GravyFace wrote:
 I was looking at implementing this in CakePHP (it's a sourceforge
 award nominee):
 http://sphinxsearch.com/

 On Fri, Jul 10, 2009 at 5:29 PM, Stinkbugjustink...@gmail.com wrote:
   
 I've done a little searching around on the web for search features for
 CakePHP.  I've found a couple of different Searchable Behaviors out
 there.  However, they all seem a bit basic.  I have a few ideas for a
 more advanced Search feature.  First, I believe a Behavior would
 probably the way to go, right?

 Second there are several features I would like to implement into a
 search, such as keyworks, like:

 yesterday (not sure)
 today (not sure)
 NOT
 OR
 AND

 I would also like to have a shell/task that could be used to create an
 index for faster searching.  I have a data model in mind already and
 some ideas for rules.

 Anyone up for helping with the challenge?  I'm up for writing most of
 it myself, but it would be great to have some outside input and
 someone who could check my code and make suggestions.  But if someone
 wants to help write some of the code, that's good too.

 I know search can be a complicated thing and this won't be Google or
 anything like that, but the bottom line for me is that it works fairly
 well and it's simple to use and implement.
 

 --~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com
 To unsubscribe from this group, send email to 
 cake-php+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/cake-php?hl=en
 -~--~~~~--~~--~--~---

   


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Beginning CakePHP from Novice to Professional book problem: has anyone read this book?

2009-07-11 Thread Jon Chin
I've read it too and had the same experience.  There's typos and errors 
here and there but your intuition usually tells you what's better.  You 
might want to check out the errata on the Packt website for that book.  
He published a bunch of corrections.


I have AJAX functionality working on my site and I only really followed 
the instructions in that book (possibly with some help from 
book.cakephp.org too).  Maybe if you give us some details on what you're 
experiencing, armen, we can help you figure out what's wrong.


Jon Chin




Matthew Bingham wrote:

I have (and a couple of others) but I haven't gotten to that chapter
yet.  Got a page number for me?

(I have 4 cake books and have found errors in 2 so far -- I've read 3.
 Both the ones I have published by PAKT are riddled with insignificant
little errors.  Things anyone would see and say 'nah I'm gonna do
this...')

On Sat, Jul 11, 2009 at 6:50 AM, womblel.e.ad...@gmail.com wrote:
  

Haven't read said book.  But have recently used the prototype library
for Ajax in Cake.

Perhaps post what you are after, and what problems you are getting.

On Jul 11, 7:15 pm, armen oldar...@gmail.com wrote:


Hi all,
I'm reading this book
Beginning CakePHP from Novice to Professional  which is  tutorial
based and it's easier to learn since it includes alot of examples. I
reached the Ajax integration chapter and i'm having problems setting
up prototype to work with my pages. has anyone encountered this error
in the book?

Thanks in advance,
-Armen

  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---

  


smime.p7s
Description: S/MIME Cryptographic Signature


Re: How to prevent circular relationships ?

2009-07-08 Thread Jon Chin
Thanks for the tip.  I installed MySQL Workbench.  It looks like a sweet 
program, but I'm not totally sure what it does for me.  I've imported my 
current database tables and created a few EER diagrams.  Other than 
database planning and documentation, what else can this tool do?  Is 
there a way to export it to something Cake can interpret?  Please 
enlighten me.


Also, when I create a relationship between tables in the program, it 
creates a new foreign key like this: tablename_id.  But Cake syntax is 
singulartablename_id.  Do you know if there's a way to change that 
Workbench default?


Jon Chin




Mike Bates wrote:
Is there a reason for Machine and Service to have many to many 
relationships (machine with Type and category, Service with customer)? 
There are often complications when you have db design with many to 
many relationships.


Try creating new tables in between them so you can have HABTM between 
machine and type, machine and category, service and customer.


When designing your schema this is a great free tool

http://dev.mysql.com/downloads/workbench/5.1.html

It'll create an EER diagram for you, and using that as a visual aid 
helps a lot when putting your schema together.



On Wed, Jul 8, 2009 at 8:08 AM, iFeghali igor.fegh...@gmail.com 
mailto:igor.fegh...@gmail.com wrote:



Hello All,

I am stuck at a circular relationship problem. This is my scenario:

- Machine HABTM Service HABTM Machine
- Machine belongsTo Type hasMany Machine
- Machine belongsTo Category hasMany Machine
- Service belongsTo Customer hasMany Service

So far so good. When the user goes to /machine/view it expects to see:

[level 0] machine
[level 1] machine type
[level 1] machine category
[level 1] services
[level 2] services customers

If I set recursive to 1, the last item will not be retrieved. If i set
recursive to 2, everything goes well except I get machine records for
type, category and services (too much unwanted data).

I could let recursive = 2 and manually unbind machine from all other
models in the view action, but that would be too much extra code for
something apparently simple. note that the given scenario is just an
exemplification, my real case has around 8 models tied on a complex
web.

I could also made relationships one way only, but obviously it would
break the views for the other models.

so my question is whether i can set recursive to 2, but tells cake not
to retrieve the main model thus preventing circular data.

Thank you.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 
Groups CakePHP group.

To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

-~--~~~~--~~--~--~---



smime.p7s
Description: S/MIME Cryptographic Signature


radios with HABTM

2009-07-01 Thread Jon Chin
I have a model (Category) that  actsAs a Tree.  User and Category has a 
HABTM relationship.  In the categories_user table, I have category_id, 
user_id, and skill.  The skill field is intended to be a 1-5 integer 
representation of how skilled that user is at that category.


My problem arises at the view where the user edits his skills.  I can't 
figure out how to create the form view code.  I set the Tree Helper to 
use this code for each node of the tree:
   $options = array('0'='0', '1'='1', '2'='2', '3'='3', '4'='4', 
'5'='5');

   if(isset($data['User']['0']['CategoriesUser']['skill']))
   {echo $form-input('CategoriesUser.skill', 
array('type'='radio', 'options'=$options, 
'default'=$data['User']['0']['CategoriesUser']['skill']));}

   else
   {echo $form-input('CategoriesUser.skill', 
array('type'='radio', 'options'=$options, 'default'='0'));}


It generates this html code:
div class=input radiofieldsetlegendSkill/legend
input type=radio name=data[CategoriesUser][skill] 
id=CategoriesUserSkill0 value=0 checked=checked  /label 
for=CategoriesUserSkill00/label
input type=radio name=data[CategoriesUser][skill] 
id=CategoriesUserSkill1 value=1  /label 
for=CategoriesUserSkill11/label
input type=radio name=data[CategoriesUser][skill] 
id=CategoriesUserSkill2 value=2  /label 
for=CategoriesUserSkill22/label
input type=radio name=data[CategoriesUser][skill] 
id=CategoriesUserSkill3 value=3  /label 
for=CategoriesUserSkill33/label
input type=radio name=data[CategoriesUser][skill] 
id=CategoriesUserSkill4 value=4  /label 
for=CategoriesUserSkill44/label
input type=radio name=data[CategoriesUser][skill] 
id=CategoriesUserSkill5 value=5  /label 
for=CategoriesUserSkill55/label/fieldset/div


What am I doing wrong?  Thanks in advance.

--
Jon Chin




smime.p7s
Description: S/MIME Cryptographic Signature


Re: app attempting to insert records rather than update

2009-06-22 Thread Jon Chin
Thanks, Brian for all your input.  I agree, the code was pretty 
difficult to understand.  After spending tons of time staring at the 
code, I realized there was a simpler and more correct way to do it.  I 
rewrote it and it's working for the most part now.  I still have to work 
out a few kinks, though.


Jon Chin




brian wrote:

That's a bit difficult to follow. At what point are you calling
_processMerit()? And you have an empty block inside wizard()? Is that
on purpose?

You have a couple of instances with $this-Merit-save($this-data)
but I only see where you're reading data from the DB for Application.
hich model are you working with?

Sorry, I've never used the WizardComponent so this is a bit opaque to me.

On Sat, Jun 20, 2009 at 2:06 AM, Jon Chinj...@boogly.net wrote:
  

Here's the code.  I still can't get it to update rather than insert.
What am I doing wrong?

 function beforeFilter() {
   $this-Wizard-steps = array('profile', 'merit', 'finance',
'education', 'endorsement');
 }

 function wizard($step = null) {
 if(isset($this-passedArgs['1']) ||
$this-Session-read('application_id')) //if application already
defined, load it
 {
   //Ensure the user is authorized to edit the application
   if(isset($this-passedArgs['1']))
   {$this-Session-write('application_id', $this-passedArgs['1']);}
   $application =
$this-Application-findById($this-Session-read('application_id'));

   if($application['Application']['user_id'] ==
$this-Auth-user('id'))
   {
   }
   else
   {
 $this-Session-setFlash('You do not have authorization to
view this.');
 $this-Session-delete('application_id');
 $this-redirect('/applications');
   }

 }
 else //if not entering with previously started application, start one
 {
   //create application record
   $this-Application-create();
   $this-Application-save(array('user_id'=$this-Auth-user('id')));
   $this-Session-write('application_id',
$this-Application-getInsertID());
 }
   $this-Wizard-process($step);
 }

   function _processMerit() {
 App::import('Sanitize');
 Sanitize::clean($this-data);
 switch($this-params['form']['action'])
 {
   case 'Continue':
 if($this-Merit-save($this-data)) {
   return true;
 }
 else
 {
   $this-Session-setFlash('Sorry, the information you\'ve
entered is incorrect.');
   return false;
 }
 break;
   case 'Back':
 $this-redirect('/applications/wizard/profile');
 break;
   case 'Save':
 if($this-Merit-save($this-data)) {
   $this-Session-setFlash('Your changes have been saved.');
 }
 else
 {
   $this-Session-setFlash('Sorry, the information you\'ve
entered is incorrect.');
 }
 break;
 }
 return false;
   }

Jon Chin



brian wrote:


On Fri, Jun 19, 2009 at 2:04 AM, Jon Chinj...@boogly.net wrote:

  

Thanks for the tip.  Sadly, I'm still having problems with it.  When I
add ?=$form-input('id');? to the view, all it does is generate input
type=hidden name=data[Application][id] value= id=ApplicationId
/ which doesn't change anything in my controller when I print the
contents of $this-data.  I also tried making the field called
application_id in the form, but it didn't have an effect either.

It's really stumping me.  Any idea what's going on?  Since my primary
key on Merit is application_id, should Cake already know that if I'm
trying to set $this-Merit-id?




The PK for Merit should be id, not application_id. That should be
a foreign key pointing to applications table.

If you post the code for the controller action we might be able to sort it out.

  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---

  


smime.p7s
Description: S/MIME Cryptographic Signature


Re: app attempting to insert records rather than update

2009-06-20 Thread Jon Chin

Here's the code.  I still can't get it to update rather than insert.  
What am I doing wrong?

  function beforeFilter() {
$this-Wizard-steps = array('profile', 'merit', 'finance', 
'education', 'endorsement');
  }
 
  function wizard($step = null) {
  if(isset($this-passedArgs['1']) || 
$this-Session-read('application_id')) //if application already 
defined, load it
  {
//Ensure the user is authorized to edit the application
if(isset($this-passedArgs['1']))
{$this-Session-write('application_id', $this-passedArgs['1']);}
$application = 
$this-Application-findById($this-Session-read('application_id'));

if($application['Application']['user_id'] == 
$this-Auth-user('id'))
{
}
else
{
  $this-Session-setFlash('You do not have authorization to 
view this.');
  $this-Session-delete('application_id');
  $this-redirect('/applications');
}
   
  }
  else //if not entering with previously started application, start one
  {
//create application record
$this-Application-create();
$this-Application-save(array('user_id'=$this-Auth-user('id')));
$this-Session-write('application_id', 
$this-Application-getInsertID());
  }
$this-Wizard-process($step);
  }

function _processMerit() {
  App::import('Sanitize');
  Sanitize::clean($this-data);
  switch($this-params['form']['action'])
  {
case 'Continue':
  if($this-Merit-save($this-data)) {
return true;
  }
  else
  {
$this-Session-setFlash('Sorry, the information you\'ve 
entered is incorrect.');
return false;
  }
  break;
case 'Back':
  $this-redirect('/applications/wizard/profile');
  break;
case 'Save':
  if($this-Merit-save($this-data)) {
$this-Session-setFlash('Your changes have been saved.');
  }
  else
  {
$this-Session-setFlash('Sorry, the information you\'ve 
entered is incorrect.');
  }
  break;
  }
  return false;
}

Jon Chin



brian wrote:
 On Fri, Jun 19, 2009 at 2:04 AM, Jon Chinj...@boogly.net wrote:
   
 Thanks for the tip.  Sadly, I'm still having problems with it.  When I
 add ?=$form-input('id');? to the view, all it does is generate input
 type=hidden name=data[Application][id] value= id=ApplicationId
 / which doesn't change anything in my controller when I print the
 contents of $this-data.  I also tried making the field called
 application_id in the form, but it didn't have an effect either.

 It's really stumping me.  Any idea what's going on?  Since my primary
 key on Merit is application_id, should Cake already know that if I'm
 trying to set $this-Merit-id?

 

 The PK for Merit should be id, not application_id. That should be
 a foreign key pointing to applications table.

 If you post the code for the controller action we might be able to sort it 
 out.

 
   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: app attempting to insert records rather than update

2009-06-19 Thread Jon Chin

Thanks for the tip.  Sadly, I'm still having problems with it.  When I 
add ?=$form-input('id');? to the view, all it does is generate input 
type=hidden name=data[Application][id] value= id=ApplicationId 
/ which doesn't change anything in my controller when I print the 
contents of $this-data.  I also tried making the field called 
application_id in the form, but it didn't have an effect either.

It's really stumping me.  Any idea what's going on?  Since my primary 
key on Merit is application_id, should Cake already know that if I'm 
trying to set $this-Merit-id?

Jon Chin




rich...@home wrote:
 Forget about storing the id in a session and just include the field in
 the form. Cake will automatically hide it from the user.

 On Jun 18, 8:55 am, Jon Chin j...@boogly.net wrote:
   
 I'm building a scholarship application using Cake.  I have an
 Application model and a Merit model and I'm using a wizard component I
 picked up from the Bakery.  The Application model has a hasOne
 relationship to Merit.  I want my users to be able to come back to edit
 the stuff they've already saved to the merits table.  My app works fine
 the first time a user goes through the process.  The problem I'm having
 is that when they want to edit the data (btw, it loads the data from the
 db fine), it attempts to insert a new record rather than update the
 current.  Here's my relevant code:

 In the controller:
 $this-Merit-id = $this-Session-read('application_id');//I've done a
 pr($this-Merit-id); and it is has the right application id
 if($this-Merit-save($this-data)) {return true;}

 In the model:
 var $name = 'Merit';
 var $belongsTo = array('Application' = array(
 'className'= 'Application',
 'foreignKey'= 'application_id'
 ));

 Any advice would be greatly appreciated.  I've been banging my head on
 the wall over this.

 Thanks,

 --
 Jon Chin
 
 
   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



app attempting to insert records rather than update

2009-06-18 Thread Jon Chin

I'm building a scholarship application using Cake.  I have an 
Application model and a Merit model and I'm using a wizard component I 
picked up from the Bakery.  The Application model has a hasOne 
relationship to Merit.  I want my users to be able to come back to edit 
the stuff they've already saved to the merits table.  My app works fine 
the first time a user goes through the process.  The problem I'm having 
is that when they want to edit the data (btw, it loads the data from the 
db fine), it attempts to insert a new record rather than update the 
current.  Here's my relevant code:

In the controller:
$this-Merit-id = $this-Session-read('application_id');//I've done a 
pr($this-Merit-id); and it is has the right application id
if($this-Merit-save($this-data)) {return true;}

In the model:
var $name = 'Merit';
var $belongsTo = array('Application' = array(
'className'= 'Application',
'foreignKey'= 'application_id'
));

Any advice would be greatly appreciated.  I've been banging my head on 
the wall over this.

Thanks,

-- 
Jon Chin



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ajax element rendering causing isUnique to misbehave

2009-06-12 Thread Jon Chin
It's taken me a little bit to track this down.  The problem is that the 
model's $this-id is not set.  How can I make it so the model has that?


Jon Chin




brian wrote:

Are you sure you're passing the model's ID? If you change the email,
is the record edited, or do you get a completely new record? Cake will
check the ID to see if the unique field it finds belongs to the
currently-edited object. If so, it should let it pass.

On Tue, Jun 9, 2009 at 1:32 PM, Jon Chinj...@boogly.net wrote:
  

I'm hoping somebody here can help me figure out how to use isUnique in
my model correctly.

I have a db table with email, name, etc.  I developed an action in my
controller and a view for the purpose of allowing the user to editing
the data stored here.  I created a rule isUnique for the email field and
it worked perfectly.

However, I needed to convert it to a page where groups of these settings
are in their own view (and I load them into the page via AJAX).  Now, it
won't let the user save changes to their profile without changing their
email (since it detects that the email they entered already exists).

Can anybody tell me why this change to AJAX element rendering is causing
this?  Or better yet, how I can fix it?  Thanks.

--
Jon Chin
801-592-5029
email: j...@boogly.net
AIM: port23user
Google Talk: port23u...@gmail.com
MSN Messenger: egghea...@hotmail.com
Yahoo Messenger: port23user





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---

  


smime.p7s
Description: S/MIME Cryptographic Signature


ajax element rendering causing isUnique to misbehave

2009-06-09 Thread Jon Chin
I'm hoping somebody here can help me figure out how to use isUnique in 
my model correctly.

I have a db table with email, name, etc.  I developed an action in my 
controller and a view for the purpose of allowing the user to editing 
the data stored here.  I created a rule isUnique for the email field and 
it worked perfectly.

However, I needed to convert it to a page where groups of these settings 
are in their own view (and I load them into the page via AJAX).  Now, it 
won't let the user save changes to their profile without changing their 
email (since it detects that the email they entered already exists).

Can anybody tell me why this change to AJAX element rendering is causing 
this?  Or better yet, how I can fix it?  Thanks.

-- 
Jon Chin
801-592-5029
email: j...@boogly.net
AIM: port23user
Google Talk: port23u...@gmail.com
MSN Messenger: egghea...@hotmail.com
Yahoo Messenger: port23user



smime.p7s
Description: S/MIME Cryptographic Signature


Re: ajax element rendering causing isUnique to misbehave

2009-06-09 Thread Jon Chin
If I change the email, the record gets edited (no new records are 
created).  In trying to debug this, I put a pr($this-data); statement 
at the beginning of the action's function.  When I change the email, all 
of the fields are there, including user_id.  However, when I leave the 
email the same, the user_id field is not included in the array.  Any 
idea why it's doing that?


Thanks,

Jon Chin




brian wrote:

Are you sure you're passing the model's ID? If you change the email,
is the record edited, or do you get a completely new record? Cake will
check the ID to see if the unique field it finds belongs to the
currently-edited object. If so, it should let it pass.

On Tue, Jun 9, 2009 at 1:32 PM, Jon Chinj...@boogly.net wrote:
  

I'm hoping somebody here can help me figure out how to use isUnique in
my model correctly.

I have a db table with email, name, etc.  I developed an action in my
controller and a view for the purpose of allowing the user to editing
the data stored here.  I created a rule isUnique for the email field and
it worked perfectly.

However, I needed to convert it to a page where groups of these settings
are in their own view (and I load them into the page via AJAX).  Now, it
won't let the user save changes to their profile without changing their
email (since it detects that the email they entered already exists).

Can anybody tell me why this change to AJAX element rendering is causing
this?  Or better yet, how I can fix it?  Thanks.

--
Jon Chin
801-592-5029
email: j...@boogly.net
AIM: port23user
Google Talk: port23u...@gmail.com
MSN Messenger: egghea...@hotmail.com
Yahoo Messenger: port23user





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---

  


smime.p7s
Description: S/MIME Cryptographic Signature