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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:26:25+00:00 2026-06-18T05:26:25+00:00

When defining rules, does the field name have to match the column name in

  • 0

When defining rules, does the field name have to match the column name in the database?

I’m having a problem where if the field name and the column name don’t match, the rules are displayed and nothing is saved to the database.

What works:

Database

user_id | username

Field

<?php echo Form::input('username', $username, array('id' => 'username')); ?><?php echo Arr::get($errors, 'username');?>

Model

class Model_User extends ORM {

    protected $_primary_key = 'user_id';

    public function rules()
    {
        return array(
            'username' => array(
                array('not_empty'),
            ),
        );
    }
}

Messages

return array(
    'username' => array(
        'not_empty' => 'You must provide a username.',
    ),
);

What doesn’t work:

Database

user_id | username

Field

<?php echo Form::input('membername', $username, array('id' => 'username')); ?><?php echo Arr::get($errors, 'membername');?>

Model

class Model_User extends ORM {

    protected $_primary_key = 'user_id';

    public function rules()
    {
        return array(
            'membername' => array(
                array('not_empty'),
            ),
        );
    }
}

Messages

return array(
    'membername' => array(
        'not_empty' => 'You must provide a username.',
    ),
);

It seems if I change the field name to something other than username the rules function doesn’t work correctly.

If I don’t apply any rules, changing username to something else doesn’t cause any problems with saving data to the database.

  • 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-18T05:26:27+00:00Added an answer on June 18, 2026 at 5:26 am

    Mapping column names from your database to different internal names is not possible. The same column name is also used for setting rules, labels etc. I don’t see why you would want to change the column names, it would be bad for a developers expectations. My advise is to rename your table columns in that case.

    The only possibility Kohana ORM provides to control your table columns is to whitelist an array of column names that is to be used. Use this variable in your ORM module:

    protected $_table_columns = array('column1','column2');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problem defining CSS rules for browsers that do not support font-stretch
When defining a resources in routes.rb in Rails, I have the following problem: My
Atleast defining my problem is simple... I have a Input control (Text) and a
I have 2 CSS files defining 2 sets of CSS rules for the same
I have a problem with defining procedures in Prolog. I have two source files
I have a css rule defining the background color as the window system color
After defining variables, functions, etc., can you save what you have done on the
When defining parameter type that is e.g. in System.Data you have no intellisense and
Does anyone have experience with trellis ? Looking at it as a framework for
I have a css rule. its job is to place the left column of

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.