So I'm using the CakePHP application framework on my local server with
PHP5. I don't know if any of you are familiar with it but I've tried
getting help from the cakephp website but nobody knew so I thought I'd
ask here.
For some reason, using CakePHP's validate function does not work on my
server when it works on others. Another person sent me an exact copy
of some code he had on his server using the same version of CakePHP
and the PHP 5 but his would validate and mine wouldn't. What happens
is, the validate function is supposed to check to see if data is
alphaNumeric and of a certain length, but instead, mine does not do
this and inserts blank entries into the database instead of displaying
errors.
So my question is, what could be wrong with my server (PHP settings or
apache settings or something) that would cause this to not validate? I
know it's definitely something wrong with my server and don't have a
clue what it'd be.
Here's the code too, if anyone could take a look. Thanks!
<?php // View for the form - what the page looks like ?>
<h2>Add Option</h2>
<form method="post" action="">
<p><?php echo $form->input('Option.name'); ?></p>
<p><?php echo $form->input('Option.value'); ?></p>
<?php echo $form->submit('Submit'); ?>
</form>
<?php
// Application model - where the validation takes place
class Option extends AppModel
{
var $name = 'Option';
// Validation
var $validate = array(
'name' => array(
'rule' => array('custom', '/\\w/'),
'allowEmpty' => false,
'message' => 'Please enter a valid name.'
),
'value' => array(
'rule' => array('custom', '/\\w/'),
'allowEmpty' => false,
'message' => 'Please enter a valid value.'
)
);
}
?>
<?php
// Controller for the application
class OptionsController extends AppController
{
var $name = 'Options';
function add()
{
if ( !empty($this->data) )
{
$this->Option->set($this->data);
if ( $this->Option->save($this->data) )
{
echo "saved";
}
else {
echo "failed validation";
}
}
}
}
?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---