Error using $validation?

2009-01-30 Thread Aurelius

Hey Guys!

Where's the Bug here, the Validation doesn't work, I can save all
input, e.g. 125.

?php
   class Post extends AppModel {
  var $name = 'Post';
  var $validate = array(
 'percent' = array(
 'rule' = array('between', 0, 100),
 'message' = 'You can only have between 0 and 100 percent
of your costumers in the test.'
  ),
 );
?

what's wrong?

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



Error using $validation?

2009-01-30 Thread Aurelius

Hey Guys!

Where's the Bug here, the Validation doesn't work, I can save all
input, e.g. 125.

?php
   class Post extends AppModel {
  var $name = 'Post';
  var $validate = array(
 'percent' = array(
 'rule' = array('between', 0, 100),
 'message' = 'You can only have between 0 and 100 percent
of your costumers in the test.'
  ),
 );
?

what's wrong?

thx
Aurelius
--~--~-~--~~~---~--~~
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: Error using $validation?

2009-01-30 Thread Miles J

Could we see the controller where the validation occurs?
--~--~-~--~~~---~--~~
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: Error using $validation?

2009-01-30 Thread Aurelius

It's the the standard bake-controller
All other field-validations works perfect.


?php
class Shop extends AppModel {

var $name = 'Shop';
var $validate = array(
'active' = array('numeric'),
'title' = array(
 'minlength' = array(
  'rule' = array('minLength', 3),
  'message' =  'The Shop title must have at least 3
characters.'
  ),
 'maxlength' = array(
  'rule' = array('maxlength', 100),
  'message' = 'The Shop title can\'t have more than 100
characters.'
  ),
),
'language_id' = array('numeric'),
'address_required' = array('numeric'),
'percent_in_test' = array(
  'rule' = array('between', 0, 100),
  'message' = 'You can only have between 0 and 100 
percent
of your costumers in the test.'
   ),
);
var $displayField = 'title';
...}




And the Controller:

?php
class ShopsController extends AppController {

var $name = 'Shops';
var $helpers = array('Html', 'Form');
...

function edit($id = null) {
if (!$id  empty($this-data)) {
$this-Session-setFlash(__('Invalid Shop', true));
$this-redirect(array('action'='index'));
}
if (!empty($this-data)) {
if ($this-Shop-save($this-data)) {
$this-Session-setFlash(__('The Shop has been 
saved', true));
$this-redirect(array('action'='index'));
} else {
$this-Session-setFlash(__('The Shop could not 
be saved. Please,
try again.', true));
}
}
if (empty($this-data)) {
$this-data = $this-Shop-read(null, $id);
}
$languages = $this-Shop-Language-find('list');
$owners = $this-Shop-Owner-find('list');
$this-set(compact('languages','owners'));
}
...
}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---