Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9065933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:37:38+00:00 2026-06-16T16:37:38+00:00

I am trying to build my first CakePHP application and I am having some

  • 0

I am trying to build my first CakePHP application and I am having some trouble with the form validation not showing when I try to add to the database. On submitting the form I get the flash message (as shown in the controller below), but the individual validation does not show.

Model:

class Client extends AppModel {

public $validate = array (

'businessName' => array (
    'mustNotBeBlank'=>array(
        'rule'=>'notEmpty',
        'message'=>'Must not be empty'
                ),
    'mustBeUnique'=>array(
        'rule'=>'isUnique',
        'message'=>'Name already registered'
                ),
    'maxLength50'=>array (
        'rule'=>array('maxLength', 50),
    'message'=>'Exceeds 50 Characters'
                )
    ),

'address1' => array (
    'mustNotBeBlank'=>array(
        'rule'=>'notEmpty',
        'message'=>'Must not be empty'
                ),
    'maxLength50'=>array (
        'rule'=>array('maxLength', 50),
    'message'=>'Exceeds 50 Characters'
                )
    ),

'address2' => array (
    'mustNotBeBlank'=>array(
        'rule'=>'notEmpty',
        'message'=>'Must not be empty'
                ),
    'maxLength50'=>array (
        'rule'=>array('maxLength', 50),
    'message'=>'Exceeds 50 Characters'
                )
    ),
'address3' => array (
    'mustNotBeBlank'=>array(
        'rule'=>'notEmpty',
        'message'=>'Must not be empty'
                ),
    'maxLength50'=>array (
        'rule'=>array('maxLength', 50),
    'message'=>'Exceeds 50 Characters'
                )
    ),

'postCode' => array (
    'mustNotBeBlank'=>array(
        'rule'=>'notEmpty',
        'message'=>'Must not be empty'
                ),
    'postCode' => array(
            'rule'=>array('postal', null, 'uk'),
            'message'=>'Please enter a valid postcode'
                    )
    ),

'telephone1' => array (
    'mustNotBeBlank'=>array(
        'rule'=>'notEmpty',
        'message'=>'Must not be empty'
                ),
    'maxLength11'=>array (
        'rule'=>array('maxLength', 11),
    'message'=>'Exceeds phone number length'
                ),
    'mustBeNumber'=>array(
            'rule' =>'numeric',
            'message' => 'Must be a number'
                    )
    ),

'telephone2' => array (
    'maxLength11'=>array (
        'rule'=>array('maxLength', 11),
    'message'=>'Exceeds phone number length'
                ),
    'mustBeNumber'=>array(
            'rule' => 'numeric',
            'message' => 'Must be a number'
                    )

    ),

'email' => array (
        'rule'    => array('email', true),
        'message' => 'Please supply a valid email address.'
),

    'domain' => array (
        'rule' => 'url',
        'message' => 'Please supply a valid email address.'
)
);

}

View (html removed for simplicity):

echo $this->form->create();
echo $this->Form->input('businessName', array('label' => 'Business Name'));
echo $this->Form->input('address1', array('label' => 'Address'));
echo $this->Form->input('address2', array('label' => ''));
echo $this->Form->input('address3', array('label' => ''));
echo $this->Form->input('postCode', array('label' => 'Postcode'));
echo $this->Form->input('telephone1', array('label' => 'Landline'));
echo $this->Form->input('telephone2', array('label' => 'Mobile'));
echo $this->Form->input('email', array('label' => 'Email'));
echo $this->Form->input('domain', array('label' => 'Domain'));

$options = array(
    'label' => 'Add',
    'div' => array(
        'class' => 'btn btn-primary',
    )
);
echo $this->Form->end($options);

Add action in controller:

public function add() {
    if ($this->request->is('post')) {
        $this->Client->create();
        if ($this->Client->save($this->request->data)) {
            $this->Session->setFlash('Client has been saved.');
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash('Unable to add your post.');
        }
    }
}

Thanks once again for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:37:39+00:00Added an answer on June 16, 2026 at 4:37 pm

    Your form creation tag is

    echo $this->form->create();
    

    but should be

    echo $this->Form->create();
    

    Notice the upper case F. Just tried both locally and the lowercase ->form fails to report error messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build my first cocoa application. done some iPhone developing before. I
I'm trying to build my first Pig UDF in Java and am having trouble
I am a beginner with CakePHP trying to build my first app. I have
I am trying to build my first CRUD application and cant get the update
Trying to build a basic 3-layer architecture in my new application suite. For first
I am trying to build my first Django project from scratch and am having
I'm trying to build my first localized application. I have all the strings in
I'm trying to build a Silverlight application where I use 5 XAMLS. The first
I am trying to build my first Postgres database schema involving inheritance. I am
I'm trying to build my first generic list and have run into some problems.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.