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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:53:32+00:00 2026-06-15T08:53:32+00:00

what I need is someone to see why CakePHP (Ver 2.2.2) is doing what

  • 0

what I need is someone to see why CakePHP (Ver 2.2.2) is doing what it is doing? OK the breakdown of my code is as follows. The DIV PageList is a JQuery Accordion, with two drop downs, one for an admin to add a new use and the other to view all users and make some changes. Add user is fine and works without any problems.

My problem is (or at lest i think it is) withe the Form Helper, I did have the Form Create call outside my foreach loop before and was working without any problems, I would find the user I wanted to change something on and then save, no problem. When I stated to pageinate the results I started to get problems. As when the Form Create was outside the foreach and just before the start of my table code, only the last results displayed would be able to save the changes made. I found the cause of the problem and that was the ID field was always defaulting to last displayed result. so I moved the Form Create to within my foreach loop.

This now works but for some reason, it starts the ends right away, therefore my inputs are now seating outside the form tags? I don’t understand why because I have the end Form Helper end() call at the bottom of the foreach loop. Therefore it should just display each user in its own form.

I am not sure if this is a issue and can still use it like this. But the one issue is that my form now starts after my table, which will not validate with W3C, this is not a big issue. Side note, is it ok to use tables still? I am listing data with them? I am trying to learn the HTML 5 spec. but have not really seen anything about tables let…

Many Thanks. Glenn Curtis.

echo '<div id="PageList">';

$OutputHolder = '<h3 class="Background-Titles">Add User</h3>';
$OutputHolder .= '<div class="Background-Content" id="AdminAddUser">';
$OutputHolder .=  $this->Form->create('User', array('url'=>'http://glenns-showcase.net/projects/cake/DrWho/adminadd/', 'inputDefaults' => array('div' => false) ) ); 
$OutputHolder .=  $this->Form->input('username');
$OutputHolder .=  $this->Form->input('password');
$OutputHolder .=  $this->Form->input('firstname');
$OutputHolder .=  $this->Form->input('surname');
$OutputHolder .=  $this->Form->input('email');
$OutputHolder .= 'Select Role For User <br />';
$OutputHolder .=  $this->Form->radio('role_id', $opt_role, $attributes);
$OutputHolder .= '<br />Select Active State For User <br />';
$OutputHolder .=  $this->Form->radio('active', $opt_active, $attributes);
$OutputHolder .=  $this->Form->end('Submit'); 
$OutputHolder .= '</div>'; //End for AddUser
echo $OutputHolder;

$OutputViewUsers = '<h3 class="Background-Titles">View All Users</h3>';
$OutputViewUsers .= '<div class="Background-Content" id="AdminViewUsers">';

$OutputViewUsers .=  '<table border="0">';
$OutputViewUsers .=  '<tr><td>Username</td><td>First Name</td><td>Surname</td><td>E-mail</td><td>Stutus</td><td>Level</td><td>Save</td></tr>';
foreach($users as $key => $value) {
    $OutputViewUsers .= $this->Form->create('UserEdit', array('url'=>'http://glenns-showcase.net/projects/cake/DrWho/adminedit/', 'inputDefaults' => array('div' => false) ) );
    $BaseLink = $users[$key]['User']; 
    $OutputViewUsers .= "<td class=\"AdminViewUsersUN\">" .($BaseLink  ['username']) . "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('fname', array('default' => $BaseLink  ['firstname'], 'label' => false,  'class' => 'AdminViewUsersFN') ) . "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('sname', array('default' => $BaseLink  ['surname'], 'label' => false,  'class' => 'AdminViewUsersSN') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('email', array('default' => $BaseLink  ['email'], 'label' => false,  'class' => 'AdminViewUsersEM') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->select('active', $ActOpts, array('empty' => false, 'default' => $BaseLink  ['active'], 'class' => 'AdminViewUsersAS') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->select('role', $RoleOpts, array('empty' => false, 'default' => $users[$key]['Role']['id'],  'class' => 'AdminViewUsersUL') ). "</td>";
    $OutputViewUsers .= $this->Form->hidden('id', array('default' => $BaseLink  ['id'], ) );
    $OutputViewUsers .= "<td>" . $this->Form->submit('Save', array('div' => false, 'class' => 'AdminViewUsersSB') ). "</td></tr>"; 
    //$test = array('label' => 'Save', 'div' => array('class' => 'AdminViewUsersSB'));
    $OutputViewUsers .=  $this->Form->end(); 

} //End of foreach loop
$OutputViewUsers .= '</table>';

$OutputViewUsers .= $this->Paginator->numbers(array('first' => 2));
$OutputViewUsers .= '</div>'; //End for AllUsers 
echo $OutputViewUsers;

echo '</div>'; //End for PageList

UPDATE :::

This is how it looks now! But this now, is more or lest how I had it before. I have added the missing tag. But this now only lets the last result work! I paginate for 5 results per page, and the top four results on the page will not work because they have the wrong ID number, each time any ‘save’ is pushed, only the id from the last result is supplied.

I am not sure what your mean by “index the input the input fields” but with “give the submit elements unique names containing the appropriate index of the associated records” as far as I was aware I was doing that, which having a hidden field that supplies the ID.

What I looks like to me is that I have to put the whole form within my loop, so that each returned result is in its own form, then there should be no error! However I cant put the start of my table within in the loop or I have a header for each result! I think I should be able to work around this issue!

Many Thanks for your help!

$OutputViewUsers = '<h3 class="Background-Titles">View All Users</h3>';
$OutputViewUsers .= '<div class="Background-Content" id="AdminViewUsers">';
$OutputViewUsers .= $this->Form->create('UserEdit', array('url'=>'http://glenns-showcase.net/projects/cake/DrWho/adminedit/', 'inputDefaults' => array('div' => false) ) );
$OutputViewUsers .=  '<table border="0">';
$OutputViewUsers .=  '<tr><td>Username</td><td>First Name</td><td>Surname</td><td>E-mail</td><td>Stutus</td><td>Level</td><td>Save</td></tr>';
foreach($users as $key => $value) {
    $BaseLink = $users[$key]['User']; 
    $OutputViewUsers .= "<tr><td class=\"AdminViewUsersUN\">" .($BaseLink  ['username']) . "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('fname', array('default' => $BaseLink  ['firstname'], 'label' => false,  'class' => 'AdminViewUsersFN') ) . "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('sname', array('default' => $BaseLink  ['surname'], 'label' => false,  'class' => 'AdminViewUsersSN') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('email', array('default' => $BaseLink  ['email'], 'label' => false,  'class' => 'AdminViewUsersEM') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->select('active', $ActOpts, array('empty' => false, 'default' => $BaseLink  ['active'], 'class' => 'AdminViewUsersAS') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->select('role', $RoleOpts, array('empty' => false, 'default' => $users[$key]['Role']['id'],  'class' => 'AdminViewUsersUL') ). "</td>";
    $OutputViewUsers .= $this->Form->hidden('id', array('default' => $BaseLink  ['id'], ) );
    $OutputViewUsers .= "<td>" . $this->Form->submit('Save', array('div' => false, 'class' => 'AdminViewUsersSB') ). "</td></tr>"; 
} //End of foreach loop
$OutputViewUsers .= '</table>';
$OutputViewUsers .=  $this->Form->end(); 
$OutputViewUsers .= $this->Paginator->numbers(array('first' => 2));
$OutputViewUsers .= '</div>'; //End for AllUsers 
echo $OutputViewUsers;

ANOTHER UPDATE ::

This now seems to work, each result is in its own form elements and all the inputs or now within the form tags. However, each result now has its own header, because I now have the table inside the form but that is now within my foreach loop, so each time it loops, it echos/prints the headers at the top of the result. I be working on this. Any help is still most welcome!!

foreach($users as $key => $value) {
    $OutputViewUsers .= $this->Form->create('UserEdit', array('url'=>'http://glenns-showcase.net/projects/cake/DrWho/adminedit/', 'inputDefaults' => array('div' => false) ) );
    $OutputViewUsers .=  '<table border="0">';
    $OutputViewUsers .=  '<tr><td>Username</td><td>First Name</td><td>Surname</td><td>E-mail</td><td>Stutus</td><td>Level</td><td>Save</td></tr>';
    $BaseLink = $users[$key]['User']; 
    $OutputViewUsers .= "<tr><td class=\"AdminViewUsersUN\">" .($BaseLink  ['username']) . "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('fname', array('default' => $BaseLink  ['firstname'], 'label' => false,  'class' => 'AdminViewUsersFN') ) . "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('sname', array('default' => $BaseLink  ['surname'], 'label' => false,  'class' => 'AdminViewUsersSN') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->input('email', array('default' => $BaseLink  ['email'], 'label' => false,  'class' => 'AdminViewUsersEM') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->select('active', $ActOpts, array('empty' => false, 'default' => $BaseLink  ['active'], 'class' => 'AdminViewUsersAS') ). "</td>";
    $OutputViewUsers .= "<td>" . $this->Form->select('role', $RoleOpts, array('empty' => false, 'default' => $users[$key]['Role']['id'],  'class' => 'AdminViewUsersUL') ). "</td>";
    $OutputViewUsers .= $this->Form->hidden('id', array('default' => $BaseLink  ['id'], ) );
    $OutputViewUsers .= "<td>" . $this->Form->submit('Save', array('div' => false, 'class' => 'AdminViewUsersSB') ). "</td></tr>"; 
    //$test = array('label' => 'Save', 'div' => array('class' => 'AdminViewUsersSB'));
    $OutputViewUsers .= '</table>';
    $OutputViewUsers .=  $this->Form->end(); 

} //End of foreach loop
  • 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-15T08:53:33+00:00Added an answer on June 15, 2026 at 8:53 am

    You are simply generating invalid HTML. You are missing an opening tr tag in the loop, but even if it were present it would be still invalid, because tr is only allowed to hold td or th elements, so the browser might render the forms outside of the table.

    See also Form inside a table

    One workaround would be to wrap the whole table inside the form, index the input the input fields, give the submit elements unique names containing the appropriate index of the associated records, and use this name on the serverside to determine which record to save. Or compare the submitted data with the database and save only the records where something was changed.

    ps. yes, tables are fine as long as they are used for what they are intended, for describing tabular data.

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

Sidebar

Related Questions

I need someone to lead/guide me where have I code wrongly because I can't
I need to ask someone for a big favor. What you see in the
Can someone see what I'm doing wrong here. I Would expect it to redirect
Can someone see what I need to change here? I am displaying an observablecollection
I need someone help. When I open https://developers.facebook.com/docs/reference/api/ and clicked https://graph.facebook.com/me/likes?access_token=blablabla , I got
Please need someone's expertise on my link; http://360webmedia.com/Store/development/index.html In my my menu_left.jpg is displaying
I need someone to back me up, or prove me wrong, in regard to
I need someone to explain the following names; Asynchronous Delegates. Asynchronous methods. Asynchronous events.
Please i need someone to help convert this query entity(c#) form. select * from
i m new to solr so i really need someone to help me understand

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.