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 7557919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:15:28+00:00 2026-05-30T12:15:28+00:00

i have table car_types ,a Controller users_controller, model Car_type and action url localhost/carsdirectory/users/dashboard dashboard.ctp(view)

  • 0

i have table “car_types” ,a Controller users_controller, model Car_type and action url

localhost/carsdirectory/users/dashboard

dashboard.ctp(view)

 <?php echo $this->Form->create('Users', array('type' => 'file', 'action' => 'dashboard')); ?>
 <select>
 <?php foreach($car_type as $key => $val) { ?>
 <option value="" selected="selected">select</option>
 <option value="<?php echo $val['Car_type']['id']; ?>">
 <?php echo $val['Car_type']['car_type']; ?>
 </option>
 <?php } ?>
 </select>
 <?php echo $this->Form->end(array('label' => 'Submit', 'name' => 'Submit', 'div' => array('class' => 'ls-submit')));?>

Car_type.php(model)

 class Car_type extends AppModel
   {
   var $name = 'Car_type';

   var $validate = array(

   'car_type' => array(

       'rule' =>'notEmpty',
       'message' => 'Plz select type.'
         )
     ); 
    }

users_controller.php(controller)

  public function dashboard(){

      $this->loadModel('Car_type'); // your Model name => Car_type

      $this->set('car_type', $this->Car_type->find('all'));

   }

but when i click submit button i want to show msg(Plz select type) and right now it’s not working i know i have problem in my code not i m not able to sort out it so plz help me

thanks in advance, vikas tyagi

  • 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-05-30T12:15:30+00:00Added an answer on May 30, 2026 at 12:15 pm

    This validation rule is to validate when you add some car type, not user.

    For this, you need put validation in User model from car_type_id field:

    class User extends AppModel {
        var $name = 'User';
    
        var $validate = array(
            'car_type_id' => array(
                'rule' => 'notEmpty',
                'message' => 'Please, select car type.'
            )
        );
    }
    

    And your form:

    $this->Form->input('car_type_id', array('options' => $car_type, 'empty' => '- select -'));
    

    Your Controller can be simply:

    $this->set('car_type', $this->User->Car_type->find('all'));
    

    However, do not know if this is your entire code to confirm the relationship between these two models are correct.

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

Sidebar

Related Questions

i have table car_types ,a Controller users_controller and action url localhost/carsdirectory/users/dashboard in users_controller.php file
this is action url: http://localhost/carsdirectory/users/dashboard . dashboad.ctp (i have select filed and in this
I have table with 50 entries (users with such details like Name Surname Location
I have a select table that is generated using view : <select id =
I have two tables in my database cars and car_types. cars table refers to
Imagine I have table like this: id:Product:shop_id 1:Basketball:41 2:Football:41 3:Rocket:45 4:Car:86 5:Plane:86 Now, this
I have table inside a div tab. The table has 40 rows in it
I have table rows of data in html being filled from a CGI application.
I have table with some fields that the value will be 1 0. This
i have table structure with 3 colums (column1, column2, column3) and i want to

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.