I have built a screen where an administrator can add and edit users. I’m able to add users without issue, but when I was testing how users can be edited, I noticed that if I have more than one user, I’m only be able to edit the last user thats listed. I’m unable to edit any other user.
Here is my code:
<?php foreach ($personel as $person) { ?>
<div id="edituser<?php echo $person['Personel']['id']; ?>" class="modal" style="display:none;">
<?php
$edituserformname = "editUser" + $person['Personel']['id'];
?>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Edit User - <?php echo $person['Personel']['firstname']; ?> <?php echo $person['Personel']['surname']; ?></h3>
</div>
<div class="modal-body iframed">
<?php echo $
<?php
echo $this->Form->create('Personel', array(
'class' => 'form-horizontal',
'id' => $edituserformname
));
echo $this->Form->input('id', array(
'type' => 'hidden',
'value' => $person['Personel']['id']
));
echo $this->Form->input('firstname', array(
'type' => 'text',
'label' => 'First Name',
'class' => 'span5',
'value' => $person['Personel']['firstname']
));
echo $this->Form->input('surname', array(
'type' => 'text',
'label' => 'Surname',
'class' => 'span5',
'value' => $person['Personel']['surname']
));
echo $this->Form->input('email', array(
'type' => 'text',
'label' => 'E-Mail',
'class' => 'span5',
'value' => $person['Personel']['email']
));
echo $this->Form->input('companyid', array(
'type' => 'hidden',
'value' => $company['Company']['id']
));
echo $this->Form->input('accesslevel', array(
'label' => 'Access Level',
'options' => $roles,
'empty' => 'Select Access Level',
'class' => 'span5',
'value' => $person['Personel']['accesslevel']
));
$pocval = array('1' => 'Yes', '0' => 'No');
echo $this->Form->input('poc', array(
'label' => 'Point of Contact?',
'options' => $pocval,
'value' => $person['Personel']['poc']
));
echo $this->Form->input('password', array(
'type' => 'text',
'label' => 'Password',
'class' => 'span5',
'value' => $company['Personel']['password']
));
echo $this->Form->input('telephone', array(
'type' => 'text',
'label' => 'Telephone',
'class' => 'span5',
'value' => $company['Personel']['telephone']
));
echo $this->Form->input('type', array(
'type' => 'hidden',
'value' => '0'
));
?>
</div>
<div class="modal-footer">
<?php
echo $this->Form->submit('Save & Close', array(
'type' => 'submit',
'class' => 'btn btn-primary',
'id' => 'editusermodal'
));
echo $this->Form->end();
?>
</div>
</div>
<?php } ?>
How can I fix this issue? I had an idea about using iFrame’s but I’m reluctant to use this method. I’d rather be able to do it through CakePHP.
Many thanks
You don’t need to use iFrame’s. It doesn’t work because your Form doesn’t close correctly.
The
$this->Form->create()and$this->Form->end()should be outside the divs.Try the following: