我对 Cakephp 很陌生,过去两个月我一直在开发一个项目,该项目使用帮助创建多页表单的向导组件。
我的问题是如何将会话数据设置为上一步流程中下一步的视图。
到目前为止,我的控制器中有这个
控制器/上传样式控制器.php
CakePlugin::load('Wizard');
class UploadstyleController extends AppController {
var $uses = array('Post');
public $components = array('Wizard.Wizard');
var $username = array();
public function beforeFilter(){
$this->layout = 'loggedinnorightbar';
$this->Auth->allow('wizard','uploadstyle','styledetails','uploadcomplete');
$this->Wizard->steps = array( 'uploadstyle','editpicture');
$this->Wizard->wizardAction = '/uploadstyle/wizard/uploadstyle';
$this->Wizard->completeUrl = '/uploadstyle/uploadcomplete';
}
public function uploadcomplete(){
}
public function wizard($step = null) {
$this->Wizard->process($step);
}
/**
* [Wizard Process Callbacks]
*/
public function processUploadstyle() {
$this->Post->set($this->data);
if($this->Post->validates()) {
return true;
}
return false;
}
public function processEditpicture() {
$uploadstyle = $this->Wizard->read();
$this->set( 'uploadstyle',$uploadstyle );
if($this->Post->validates()) {
return true;
}
return false;
}
我不会为保存数据而烦恼,因为它工作正常。
在我看来uploadstyle/editpicture.ctp
<div class="signupwrapper" style="position:relative; width:470px; margin-top:30px;">
<?php echo $this->Form->create('Uploadstyle', array('id' => 'UploadstyleForm', 'url' => '/uploadstyle/wizard/editpicture'));
echo $this->Form->hidden('Post.shines', array('value' => 0));
echo $uploadstyle['Post']['image_name'];
?>
<div class="submit">
<?php echo $this->Form->submit('Continue', array('div' => false)); ?>
<?php echo $this->Form->submit('Cancel', array('name' => 'Cancel', 'div' => false)); ?>
</div>
<?php echo $this->Form->end(); ?>
</div>
关于 'echo $upload['Post']['image_name']' 组件中是否有我需要激活的东西,或者我在视图中错误地引用了数组?
任何帮助将不胜感激!
如果这是一个很长的问题,我很抱歉,这是我第一次在这里提问。