Newbie question on form validating

2008-12-11 Thread AJV

Just starting on Cake (1.2.0). I'm trying to make a form that checks
if a code that a user has inputted is in the correct format, then
check if it's found in a database. If the first check/validation
fails, it returns the user to the first page and displays an error
above the code-field.

And I don't understand how it's done.

What are the steps in achieving this? Is there a tutorial about this?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie question on form validating

2008-12-11 Thread AJV

I'm really confused with this - can't get even the simplest examples
working.

I set a test case like this:

?php
//app/model/Contact.php
class Contact extends AppModel
{
var $name = 'Contact';
var $validate = array(
'email' = array(
'rule' = array('email', true),
'message' = 'Please supply a valid email address.'
)
);

}
?

###
?php
// app/controllers/contacts_controller.php
class ContactsController extends AppController {

var $name='Contacts';
var $uses = array('Contact');
var $helpers = array('form');

function add(){

if( !empty( $this-data ) ){

if ($this-Contact-validates()){
echo yes;
}

if( $this-Contact-save( $this-data ) ){
$lastId = $this-Contact-getLastInsertId();
$this-flash('Your new user has been created.','/c/
contacts/view/'.$lastId );
}
}
}
}
?



!-- /app/views/contacts/add.thtml  --
h1Enter Contact Information/h1

form method=post action=?php echo $html-url('/contacts/add')?


?php echo $form-label('Contact.email', Contact's E-mail); ?
?php echo $form-error('Contact.email'); ?
?php echo $form-text('Contact.email', array('size' = '80') ); ?


 br /
?php echo $form-submit('Check validity'); ?
/form

When I submit anything, like  or 1oi321 or whatever,
everything validates. The e-mail addresses also validate, which is
nice :) but it clearly isn't working at all. What am I missing? Wrong
configuration? My cake version is 1.2.0.7692 RC3.


On Dec 11, 11:38 am, gearvOsh [EMAIL PROTECTED] wrote:
 I just finished doing this today, these two links should help:

 http://book.cakephp.org/view/125/Data-Validationhttp://groups.google.com/group/cake-php/browse_thread/thread/d5e98df3...
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie question on form validating

2008-12-11 Thread AJV

A small typo - the path to the model file is of course /app/models/.

BUT I just noticed that I can change the model file to whatever, even
remove it, and it still works. Is this normal?!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie question on form validating

2008-12-11 Thread AJV

I'm quessing this has something to do with communicating with the
model file. Even if I write die() or some broken code to the model,
nothing happens. Are there any ways to confirm that the controller
talks to the model, and if not, how could it be fixed?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie question on form validating

2008-12-11 Thread AJV

OK, thanks for that info!

Still, the problem persists.

I installed a fresh cake and made this tutorial:

http://bakery.cakephp.org/articles/view/multiple-rules-of-validation-per-field-in-cakephp-1-2

But even though I followed every step, it just doesn't work, no
validation is happening.



On Dec 11, 1:48 pm, grigri [EMAIL PROTECTED] wrote:
 Yes; Cake supports dynamic models.

 If you don't create an actual model file, cake will instantiate an
 instance of AppModel with the name and useTable set up to work
 properly. This is only useful for basic models though as you can't
 specify associations, behaviors, validation or anything specific for
 the auto-model.

 Its main use is for join tables in HABTM.

 hth
 grigri

 On Dec 11, 11:29 am, AJV [EMAIL PROTECTED] wrote:

  A small typo - the path to the model file is of course /app/models/.

  BUT I just noticed that I can change the model file to whatever, even
  remove it, and it still works. Is this normal?!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Newbie question on form validating

2008-12-11 Thread AJV

:D

Well I guess I just confirmed my newbie status, I had written the
names of the model files Capitalized. I noticed that small letters
work much better :D

Well, that was a fun couple of hours.

Aapo

On Dec 11, 2:49 pm, AJV [EMAIL PROTECTED] wrote:
 I'm quessing this has something to do with communicating with the
 model file. Even if I write die() or some broken code to the model,
 nothing happens. Are there any ways to confirm that the controller
 talks to the model, and if not, how could it be fixed?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Differences between Session types?

2008-12-11 Thread AJV

The project I'm working on is expected to get a good load of visitors,
so I need to make sure I tune my cake to work as efficiently as
possible. Are there any speed/reliability issues between php (native
php sessions) and cake (filesystem) -types of sessions?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---