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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:23:29+00:00 2026-05-17T17:23:29+00:00

Simple question from an absolute n00b. I’m trying to create an edit content screen

  • 0

Simple question from an absolute n00b.

I’m trying to create an edit content screen based on the code given in the Blog Tutorial on the Cake site.

Here’s my edit function in the controller (it’s named Contents):

function edit( $id = null ) {
    $this->Content->id = $id;
    Debugger::dump( $this->Content->id );
    if( empty( $this->data ) ) {
        $this->data = $this->Content->read();
        Debugger::dump( $this->Content );
    }
    else {
        if( $this->Content->save( $this->data ) ) {
        $this->Session->setFlash( 'Content has been updated.' );
        $this->redirect( array('action' => 'index') );
        }
    }
}

And this is edit.ctp:

echo $form->create( 'Content', array('action' => 'edit') );
echo $form->input( 'id', array('type' => 'hidden') );
echo $form->input( 'title' );
echo $form->input( 'nicename' );
echo $form->end( 'Save' );

However, when I visit the Edit screen, the input fields are NOT GETTING POPULATED with the requested data.

I’m using HTML Helper to generate the links and my edit link takes the form of:

http://localhost/contents/edit/id:4c8efaa0-02fc-46bf-ac65-06a07614f57d

As you can see, I’ve introduced two Debugger dumps in the controller’s edit function… those are showing that $this->Content->id remains NULL when I visit this url.

BUT, if I modify the URL to this form (notice that I’ve used ‘=’ instead of a ‘:’):

http://localhost/contents/edit/id=4c8efaa0-02fc-46bf-ac65-06a07614f57d

Debugger reports $this->Content->id to have the correct value…

However, my fields still don’t get populated.

The index function is working fine though…

function index() {
    $this->set( 'contents', $this->Content->find( 'all' ) );
}

The above function is listing the contents correctly!

Where am I going wrong? Am I missing out on some essential bit of code in the View ?
Any help will be much appreciated.

Thanks,
m^e

  • 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-17T17:23:30+00:00Added an answer on May 17, 2026 at 5:23 pm

    The problem is here:

    http://localhost/contents/edit/id:4c8efaa0-02fc-46bf-ac65-06a07614f57d
    

    Basically your url should look like:

    http://localhost/contents/edit/4c8efaa0-02fc-46bf-ac65-06a07614f57d
    

    As you may notice the id: is missing from the correct url. The reason: If you pass the id: this is named parameter and it’s not assigned to $id in the function.

    Your link for the edit form should look like this:

    $this->Html->link('Edit', array('controller'=>contents', 'action'=>'edit', $id_variable));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a language-agnostic question about an algorithm. This comes from a (probably simple)
Simple question: Can I mix in my desktop application Java and JavaFX Script code?
Another simple question from silly old me. We keep hearing big numbers being thrown
Simple question. How can I pass a variable from the URL to the view?
Simple question, but one that I've been curious about...is there a functional difference between
Simple question, how do you list the primary key of a table with T-SQL?
Simple question - I've got a bucketload of cruddy html pages to clean up
Simple question that keeps bugging me. Should I HTML encode user input right away
Simple question: Can a swing frame be completely modal ( block all others windows
Simple question, hopefully an easy way and just want to verify I'm doing it

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.