1

I have built a component which has two tables of data, these are related by an ID.

I have it working so that when you are viewing table A, you can click a field and proceed to the view of table B - which is filtered by the the ID from table A.

My last challenge: When the user clicks the AddNew button when viewing table B we need to take the related ID into the addnew form so it saves in a hidden field.

Any pointers welcomed please! Up against a deadline, pulling too much hair out, and overdosing on caffeine!!

4

1 回答 1

1

你可以:

一个。在具有相关id的表A的视图中添加一个隐藏字段

<form method="post" name="adminForm" id="adminForm" > 
    ...
    <input type="hidden" name="yourid" value="...." />
</form>

湾。覆盖add()表 B 字段(扩展的字段)的控制器中的函数,JControllerForm在重定向 url 中添加yourid参数

class ...Controller... extends JControllerForm {

    public function add() {
        //...
        $yid = $app->input->get('yourid');
        $this->setRedirect(JRoute::_('index.php?option=' . 
            $this->option . '&view=' . $this->view_item .
            '&yourid=' . $yid . $this->getRedirectToItemAppend(), false));
        //...
    }
}

C。在表 b 的模型中,您可以获取yourid输入参数,并编辑其余查询。

  public function __construct($config = array()) {
        // .. 
        $this->yid = $app->input->get('yourid');
        parent::__construct($config);
  }

希望这可以帮助。

于 2014-06-16T08:14:08.080 回答