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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:45:54+00:00 2026-06-12T01:45:54+00:00

If I have: // Controller $this->Model->id = $id; $this->request->data[‘Model’] = $this->Model->read(); And then: //

  • 0

If I have:

// Controller
$this->Model->id = $id;
$this->request->data['Model'] = $this->Model->read();

And then:

// View (input field)
$this->Form->input('some_field'); // THE FORM FIELD WILL BE PRE-POPULATED

But if I want it to be a select box instead:

// View (with select)
$this->Form->select('some_field', $options); // THE SELECT BOX ISN'T PRE-POPULATED

Questions then:

a. Why isn’t the select-box pre-populated like the input field is?

b. Do I really have to manually pre-populate like this?

// View (with select)
$this->Form->select('some_field', $options, array('value' => $this->request->data['Model']['some_field'])); // THE SELECT BOX IS PRE-POPULATED

c. Is the above method the most efficient method of pre-populating select boxes which already has a value?

  • 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-12T01:45:55+00:00Added an answer on June 12, 2026 at 1:45 am

    no, some_field would be prepoluated by your passed form data if you would do it correctly.
    did you debug what you produced there? a multi-level array which is not cake standard.

    the correct approach would be:

    $this->request->data = $this->Model->read();
    

    since the array already contains the Model key (which debug() would have shown!).
    but careful to do this only if not posted!

    to your last question, no, if possible, use the controller or at least default. value would make your form lose the previously selected value if validation fails.

    my old cake1.3 post might also shed some light on it: http://www.dereuromark.de/2010/06/23/working-with-forms/

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

Sidebar

Related Questions

Well i have a complex form view model like this : public class TransactionFormViewModel
I have the following Model and Controller files, and when i visit this url,
In my ASP.NET MVC app, I have a view that's calling Html.Action(MyAction, this.Model) -
I have my Controller which pass Data from to view as below: IEnumerable<MovieDetails> jsonData
I have a controller with store, model and view (toolbar) : Ext.define('Cc.controller.Headers', { extend:
I have controller users . In this controller I have action account which is
I have this controller: public class StandingsController : Controller { public ViewResult Index(int id)
I have this controller in Code Igniter application. A value is initialized in the
I have this controller in Code Igniter that begins with class MyController extends CI_Controller
I have a controller like this : @Secured(['ROLE_USER','IS_AUTHENTICATED_FULLY']) def userprofile(){ def user = User.get(springSecurityService.principal.id)

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.