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

  • Home
  • SEARCH
  • 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 6208975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:54:03+00:00 2026-05-24T05:54:03+00:00

Is it possible to create model rules that are dependent from selection? I have

  • 0

Is it possible to create model rules that are dependent from selection?

I have a model “Deposit” which is used to enter the money transfer details..I have drop down list with two possible choices “Cash Transfer”,”Cheque Transfer”, and i have fields cash_deposit_date,bank_name.. which is required only for cash transfer and cheque_date, cheque_no and in_favour_of.. which is required only at the time of cheque transfer.. how can i do that..?

I know i can use scenarios like this,

$model=new Deposit("cash_transfer");

or

$model=new Deposit("cheque_transfer");

but how can I change scenario depending on the value selected in dropdown list?

  • 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-24T05:54:04+00:00Added an answer on May 24, 2026 at 5:54 am

    Couldn’t you just do this:

    Generated HTML:

    <form>
    ....
    <select name="scenario">
        <option value="cash_transfer">Cash Transfer</option>
        <option value="cheque_transfer">Checque Transfer</option>
    </select>
    ....
    </form>
    

    Code:

    // allow only lowercase letters and underscore
    $scenario = preg_replace('/[^a-z_]/', '', $_POST['scenario']);
    
    if (!empty($scenario)) {
        $model = new Deposit($scenario);
    } else {
        die('Missing scenario!');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using EF, is it possible to create the model from a disconnected dataset? Keep
Is it possible to create a SQL DB from a Linq2Sql model? I managed
Is it possible to create a join table without a model. I have a
Is it possible to create one model that stands for two different objects? for
I am wanting to create a Model that has a property of Service which
Is it possible to create Entity Data Model (edmx file) from MS Access Database
So assume I have used rails generate to create a model and subsequently it
Is it possible to create/have a non-modal .net OpenFileDialog I have a UI element
Is it possible to create a trigger that will not be in a transaction?
In my web application, I create some framework that use to bind model data

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.