Formatting Dates in a Select form Field?

2009-09-11 Thread gedm

I have an array of data ($rounds) retrieved from a find('list')
command which looks like:
[1] = 2009-09-06
[2] = 2009-09-13
[3] = 2009-09-20
[4] = 2009-09-27
[5] = 2009-10-04
[6] = 2009-10-11
[7] = 2009-10-18
[8] = 2009-10-25
[9] = 2009-11-01
[10] = 2009-11-08
[11] = 2009-11-15

The dates populate a Select form field using the view code
$form-input('round_id');

I would like to reformat the dates in the Select field to d-mmm

How do I reformat the values in the Select form field?

Thanks

Gerard
--~--~-~--~~~---~--~~
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: Request help with a model definition.

2009-08-30 Thread gedm

delocalizer Brian,

I changed the structure of my comments table by changing comment_id to
parent_id and used the find('threaded') function to retrieve the
data.  I also removed the ParentComment and ChildComment associations
from the model.

It is now working.

Thanks for your help.


On Aug 25, 8:23 pm, delocalizer conrad.leon...@hotmail.com wrote:
 Hi Gerard,
 consider using Tree behaviour for your Comments 
 model?http://book.cakephp.org/view/91/Tree

 On Aug 25, 8:43 pm,gedmgerard.me...@gmail.com wrote:

  Brian,

  Sorry if I wasn't clear.  The problem is the ChildComment User_ID
  doesn't associate with the User Model so I can't get the username
  information for the ChildComments.  I jst don't know how to assicate
  the ChildComment model with the User model.  I'm sure it's very easy I
  just can't get my head around associating with the ChildComment Class
  when it's not actually a table.  I know newbie.

  Gerard

  On Aug 25, 2:15 am, brian bally.z...@gmail.com wrote:

   On Sun, Aug 23, 2009 at 9:23 AM,gedmgerard.me...@gmail.com wrote:

Hi,

I am very new to Cake and have searched for an answer to this but
can't quite get my head around it enough to ask ask the right
question.

   I'm not sure you asked anything. What's your question?

   The debug array you posted looks ok to me. That is, if $id = 1. Is
   that the case? Have you reied it with $id = 2? You should see the
   ParentComment then, and the ChildComment array should be empty.
--~--~-~--~~~---~--~~
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: Request help with a model definition.

2009-08-28 Thread gedm

Brian and  delocalizer

I made the changes to the User model as you suggested but it made no
difference to the dubug.  The ChildComment and User tables are still
not associated when I retrieve the comment data.

I think the missing link is I need to somehow define a belongsTo link
from the ChildComment to the User model?  How do I do this?  Is this
done in the comment.php model file or a new child_comment.php file?

I had a look at the tree helper but I'm not sure how this will resove
the problem of the association between the ChildComment and User
models.  It will build the relationships between each comment but I'm
not sure how it will help with the association between the
ChildComments and User data.  I'll need to have a play with it and get
back to you.

Thanks for your help.


On Aug 26, 12:57 am, brian bally.z...@gmail.com wrote:
 On Tue, Aug 25, 2009 at 6:43 AM,gedmgerard.me...@gmail.com wrote:

  Brian,


 I see now. Try doing this for the User model:

 var $hasMany = array(
            'Comment' = array(
                            'className' = 'Comment',
                            'foreignKey' = 'user_id',
                            'dependent' = true
            ),
            'ParentComment' = array(
                            'className' = 'Comment',
                            'foreignKey' = 'user_id',
                            'dependent' = true
            ),
            'ChildComment' = array(
                            'className' = 'Comment',
                            'foreignKey' = 'user_id',
                            'dependent' = true
            )
 );

 I think that might work. Note that I set dependent = true here. This
 will remove all Comments that belong to a User if the latter is
 deleted. You'd likely want to do the same for, say, an Article model,
 or whatever it is that these Comments belong to besides User.
--~--~-~--~~~---~--~~
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: Request help with a model definition.

2009-08-25 Thread gedm

Brian,

Sorry if I wasn't clear.  The problem is the ChildComment User_ID
doesn't associate with the User Model so I can't get the username
information for the ChildComments.  I jst don't know how to assicate
the ChildComment model with the User model.  I'm sure it's very easy I
just can't get my head around associating with the ChildComment Class
when it's not actually a table.  I know newbie.

Gerard


On Aug 25, 2:15 am, brian bally.z...@gmail.com wrote:
 On Sun, Aug 23, 2009 at 9:23 AM, gedmgerard.me...@gmail.com wrote:

  Hi,

  I am very new to Cake and have searched for an answer to this but
  can't quite get my head around it enough to ask ask the right
  question.

 I'm not sure you asked anything. What's your question?

 The debug array you posted looks ok to me. That is, if $id = 1. Is
 that the case? Have you reied it with $id = 2? You should see the
 ParentComment then, and the ChildComment array should be empty.
--~--~-~--~~~---~--~~
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 to save a record but not clear an empty field?

2009-08-24 Thread gedm

delocalizer and Dr. Loboto,

It works a treat.

In the controller after fetching the data I unset the password field.
The password then comes up blank in the edit form.

I then entered the beforeValidate function, you gave me, in the model
and it works perfectly.

Thanks for your help.


On Aug 24, 3:23 pm, delocalizer conrad.leon...@hotmail.com wrote:
 Yes nice, I hadn't though of that. So you would test for:
 if (isset($this-data['User]]['password'])  $this-data['User']
 ['password'] == Security::hash(Configure::read('Security.salt')))

 On Aug 24, 1:27 pm, Dr. Loboto drlob...@gmail.com wrote:

   If you do this you'll have to hash your own password rather than let
   Auth do it automatically, because Auth will hash a blank password and
   the 'if' condition will never be true.

  If do not touch Auth hashing behavior password field can be checked
  not as notBlank but by comparison with hashed empty string.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Request help with a model definition.

2009-08-23 Thread gedm

Hi,

I am very new to Cake and have searched for an answer to this but
can't quite get my head around it enough to ask ask the right
question.  I'm hoping someone here can point me in the right
direction.

I have 2 tables, Users and Comments.  Each User has many comments.  I
have defined the Comments table as follows:
FieldType
id   int(11)  auto_increment
titlevarchar(150)
comment  text
user_id  int(11)
comment_id   int(11)

The comment_id refers back to the id field in the same table to track
the parent comment vs the child comment.  The problem is when I
retrieve
the data the user_id and user table aren't joined for the
childcomments.


An example of the data for a
parent comment might be:
id:   1
Title:  This is a parent Comment Title
comment:  This is the first comment.  The Parent.
user_id:  1
comment_id:

The Child comment of this might be:
id:   2
Title:
comment:  This is the child comment to comment number 1
user_id:  121
comment_id:  1

The comment_id is 1 to indicate this comment belongs to the parent
comment with ID = 1

My user.php model is:
class User extends AppModel {
var $name = 'User';

var $hasMany = array(
'Comment' = array(
'className' = 'Comment',
'foreignKey' = 'user_id',
'dependent' = false
)
);
}

My comment.php model is:
class Comment extends AppModel {
var $name = 'Comment';
var $belongsTo = array(
'User' = array(
'className' = 'User',
'foreignKey' = 'user_id'
),
'ParentComment' = array(
'className' = 'Comment',
'foreignKey' = 'comment_id'
),
);


var $hasMany = array(
 'ChildComment' = array(
 'className' = 'Comment',
 'foreignKey' = 'comment_id'
)
);
}


The comments controller view action is as follows:
function view($id = null) {
if (!$id) {
$this-Session-setFlash(__('Invalid Comment.', true));
$this-redirect(array('action'='index'));
}
$this-set('comment', $this-Comment-read(null, $id));
}



The debug($comment) results in the following:
Array
(
[Comment] = Array
(
[id] = 1
[title] = New Comments Site
[comment] = Hi all,
I am working on a new comments site.  Please be patient while I get
everything working properly.
Thanks
[user_id] = 1
[comment_id] = 0
)

[User] = Array
(
[id] = 1
[login] = gedm
[fullname] = gedm
[role_id] = 1
[password] = 245cb65084c076918943eaeb73dec56f2e1a3e54
[email] = g...@anemail.com
[active] = 1
)

[ParentComment] = Array
(
[id] =
[title] =
[comment] =
[user_id] =
[comment_id] =
)

[ChildComment] = Array
(
[0] = Array
(
[id] = 2
[title] = Sub comment
[comment] = This is a sub comment of one.
[user_id] = 2
[comment_id] = 1
)
)
)

Any help or suggestions would be appreciated.

--~--~-~--~~~---~--~~
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 to save a record but not clear an empty field?

2009-08-23 Thread gedm

I'm wondering how the cakephp bakery site ignores the blank password
field when a user is updating their profile?

That is, if the password is left blank it updates the other fields in
the record but does not clear the password when the record is saved.
How is this done?

Thanks

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Help with a Model definition pls

2009-08-22 Thread gedm

Hi,

I am very new to Cake and have searched for an answer to this but
can't quite get my head around it enough to ask ask the right
question.  I'm hoping someone here can point me in the right
direction.

I have 2 tables, Users and Comments.  Each User has many comments.  I
have defined the Comments table as follows:
FieldType
id   int(11)  auto_increment
titlevarchar(150)
comment  text
user_id  int(11)
comment_id   int(11)

The comment_id refers back to the id field in the same table to track
the parent comment vs the child comment.  An example of the data for a
parent comment might be:
id:   1
Title:  This is a parent Comment Title
comment:  This is the first comment.  The Parent.
user_id:  1
comment_id:

The Child comment of this might be:
id:   2
Title:
comment:  This is the child comment to comment number 1
user_id:  121
comment_id:  1

The comment_id is 1 to indicate this comment belongs to the parent
comment with ID = 1

My user.php model is:
class User extends AppModel {
var $name = 'User';


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---