模式情况下,我们有两个型号Yii中,有几个以某种形式
class Base extends AbstractModel
{
public $id;
public $name;
public function tableName()
{
return 'table_base';
}
}
class ExtendBase extends AbstractModel
{
public $id;
public $baseID;
public function tableName()
{
return 'table_base_extend';
}
}
我就不一一介绍了所有,只是描述了主要的事情。
所以,现在我想要创建将结合这种形式的表单。并希望在行动做这样的事
public function actionSome()
{
$oBase = new Base();
$aExtendBase = array(); // important this is array
for ($i = 1; $i <= 3; $i++) {
$aExtendBase[] = new Extend(); // fill in array, pre-create for form
}
if ($this->isPost()) { // protected custom method
if (isset($_POST['Base'], $_POST['ExtendBase'])) // here should be specific checker because we have several ExtendBase instances in form
{
// save Base model
// save each ExtendBase model
}
}
$this->render('formView', array('oBase' => $oBase, 'aExtendBase' => $aExtendBaes))
}
所以问题是
- 如何创建视图等“组合拳”的形式;
- 如何在POST操作后获取所有表单数据(我的意思是每个数据);
只有当我们有不同的型号时它才会有效。但是我们也一样,所以在我们的情况下不起作用。 – user1954544