我有 admin_form.ctp 文件。当我用空白数据提交它时,蛋糕验证工作正常,但问题是表单更改和 url 的布局是相同的。我的意思是页面的所有验证和 url 都是正确的,但页面的布局发生了变化。
如果任何机构有任何建议,请尽快让我知道。谢谢。
admin_form.ctp
<?php echo $this->Form->create('Page');
echo $this->Form->input('id');
?>
<div>
<?php echo $this->Form->input('title',array('onblur' => "MetaTitle()",'class'=>'sprited')); ?>
</div>
<div>
<?php echo $this->Form->input('alias',array('class'=>'sprited')); ?>
</div>
<div>
<?php echo $this->Form->input('description',array('type' => 'textarea' , 'class' => 'ckeditor sprited')); ?>
</div>
<div>
<?php echo $this->Form->input('meta_title',array('class'=>'sprited')); ?>
</div>
<div>
<?php echo $this->Form->input('meta_keyword',array('class'=>'sprited')); ?>
</div>
<div>
<?php echo $this->Form->input('meta_description',array('class'=>'sprited')); ?>
</div>
<div class="status">
<?php echo $this->Form->input('status',array('class'=>'sprited')); ?>
</div>
<div class="clear"></div>
<div id="actions">
<input type="submit" class="save" value="Save" />
<?php
echo $this->Html->link(__('Cancel'), array(
'action' => 'index',
), array(
'class' => 'cancel',
));
?>
控制器代码:-
public function admin_add() {
$this->layout = 'admin';
$this->set('title_for_layout', __('Add new page', true));
if (!empty($this->request->data)) {
$this->Page->create();
$this->request->data['Page']['user_id'] = $this->Auth->User('id');
if($this->data['Page']['alias']==""){
$this->request->data['Page']['alias']=$this->data['Page']['title'];
}
$this->request->data['Page']['alias'] = $this->title_to_alias(trim($this->data['Page']['alias']));
if ($this->Page->save($this->request->data)) {
$this->Session->setFlash(__('The page has been saved.'), 'default', array('class' => 'success'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The page could not be saved. Please, try again.'), 'default', array('class' => 'error'));
}
}
$this->render('admin_form');
}