Hi,
So I have a users controller with an action called "selfView" it looks like this: (*users_controller.php*)
function selfView() {
$user = $this->User->find('first', array('conditions' => array('User.id' => $this->Auth->user('id'))));
$formms = $this->Form->find('all', array('fields' => array('Form.id', 'Form.name'), 'recursive' => -1));
$this->set(compact('user', 'formms'));
$this->render('view');
}
This renders a profile page which has one form on it. This is the first form rendered on the page and it works just fine as you would expect.
View code snippet: (users/view.ctp)
<div id="passwordChange">
<?php echo $form->create('User', array( 'action' =>'updatePass' ));?>
<fieldset>
<legend><?php __('Change Password');?></legend>
<?php
$options = array('type'=>'password', 'div' => array('class' => 'required'));
echo $form->input(__('old_password', true), $options);
$options = array('div' => array('class' => 'required'), 'error' => array('confirmPassword' => __('Passwords do not match please try again',true), 'noempty' => __('Please provide a password',true)));
echo $form->input(__('password', true), $options);
$options = array('type'=>'password', 'div' => array('class' => 'required'));
echo $form->input(__('confirmation_password', true), $options);
echo $form->hidden('User.id', array('value' => $user['User']['id']));
?>
</fieldset>
<?php echo $ajax->submit(__('Change Password', true), array('url' => array('controller' => 'users', 'action' => 'updatePass'),
'update' => 'storage',
'complete' => '$("#UserUpdatePassForm input[type=password]").val(""); '));
$form->end();?>
<a href="#">Cancel</a>
</div>
the HTML that is Produced form "users/view.ctp":
<form action="/high-school-app/users/updatePass" method="post" id="UserUpdatePassForm">
<fieldset style="display: none;">
<input type="hidden" value="POST" name="_method">
</fieldset>
<fieldset>
<legend>Change Password</legend>
<div class="required">
<label for="UserOldPassword">Old Password</label>
<input type="password" id="UserOldPassword" value="" name="data[User][old_password]">
</div>
<div class="required required">
<label for="UserPassword">Password</label>
<input type="password" id="UserPassword" value="" name="data[User][password]">
</div><div class="required required">
<label for="UserConfirmationPassword">Confirmation Password</label>
<input type="password" id="UserConfirmationPassword" value="" name="data[User][confirmation_password]">
</div>
<input type="hidden" id="UserId" value="" name="data[User][id]">
</fieldset>
<div class="submit">
<input type="submit" onclick="return false;" id="submit2026598409" value="Change Password" update="storage">
</div>
<script type="text/javascript">
//<![CDATA[
jQuery('#submit2026598409').click( function() { jQuery('#submit2026598409').parents('form').ajaxSubmit({beforeSend:function(request) {request.setRequestHeader('X-Update', 'storage');}, complete:function(request, textStatus) {$("#UserUpdatePassForm input[type=password]").val(""); }, success:function(data, textStatus) {jQuery('#storage').html(data);}, async:true, type:'post', url:'/high-school-app/users/updatePass'}); return false;});
//]]>
</script>
<a href="#">Cancel</a>
</form>
Then I call and element that will also render a form. (users/view.ctp)
echo $this->element('my_apps' , array('applications' => $applications));
And then this is where it all goes wrong. No matter what I try I can not get this second form to print out correctly. The middle part of the form will print out,just not the opening and closing tags. With out them the form is useless to me. At this point and I really do not want to write it out by hand.
This is the code in my element that I am trying to use to output the form(*elements/my_apps.ctp*):
<?php echo $form->create('Applications', array( 'url' => array('controller' => 'applications', 'action' => 'assign', 'id' => null))); ?>
<fieldset>
<legend><?php __('Assign Application to User');?></legend>
<?php
$options = array('--' => __('Select One',true), 'test' => 'test', 'test2' => 'test2');
echo $form->label('Application.form_id', __('Form Name',true).":");
echo $form->select('Application.form_id', $options, $selected = '--');
echo $form->hidden('Application.user_id', array('value' => $user['User']['id']));
?>
</fieldset>
<?php echo $form->end(__('Assign', true));?>
this is what "*elements/my_apps.ctp*" prints out:
<fieldset style="display: none;">
<input type="hidden" value="POST" name="_method">
</fieldset>
<fieldset>
<legend>Assign Application to User</legend>
<label for="ApplicationFormId">Form Name:</label>
<select id="ApplicationFormId" name="data[Application][form_id]">
<option value=""></option>
<option selected="selected" value="--">Select One</option>
<option value="test">test</option>
<option value="test2">test2</option>
</select>
<input type="hidden" id="ApplicationUserId" value="" name="data[Application][user_id]">
</fieldset>
<div class="submit">
<input type="submit" value="Assign">
</div>
It WILL NOT Print the opening and closing tags which should be something like this:
<form action="/high-school-app/applications/assign" method="post" id="ApplicationAssignForm">
.....
.....
</form>
Any ideas? Something that I should try to do to debug would be helpful.
Update:
I just tried witting the code in by hand and even that is being stripped out. Is there some sort of post-processing going? Could that be responsible for removing my form tags?