xen:listitem problems, var not being sent to controller

Robust

Well-known member
Here's part of my template:

Code:
<ol class="FilterList">
            <xen:foreach loop="$groups" value="$group">
                <xen:listitem
                    id="{$group.group_id}"
                    label="{$group.group_name}"
                    href="{xen:adminlink 'apgroups/groups/edit', $group}"
                    delete="{xen:adminlink 'apgroups/groups/delete', $group}">
                </xen:listitem>
            </xen:foreach>
        </ol>

Code:
    protected function _getGroupAddEditResponse($group)
    {
        $viewParams = array(
            'group' => $group
        );

        return $this->responseView('Apantic_Groups_ViewAdmin_Groups_AddEdit', 'apgg_group_edit', $viewParams);
    }

    public function actionGroupsAdd()
    {
        return $this->_getGroupAddEditResponse(array());
    }

    public function actionGroupsEdit()
    {
        $groupId = $this->_input->filterSingle('group_id', XenForo_Input::UINT);
        $group = $this->_getGroupOrError($groupId);

        return $this->_getGroupAddEditResponse($group);
    }

The form is sent to the edit (actionGroupsEdit)
<xen:form action="{xen:adminlink apgroups/groups/edit}" class="section">

While on the groups list, if I dump the $group var, it dumps fine and contains a group_id. My problem is that when you are redirected by clicking on the list item, the group_id var suddenly disappears and it errors out saying no group ID exists, and that's right, I tried dumping $this->_input and it doesn't contain any input vars thru GET or POST.

Code:
    protected function _getGroupOrError($id)
    {
        $info = $this->_getGroupsModel()->getGroupById($id);
        if(!$info)
        {
            throw $this->responseException($this->responseError(new XenForo_Phrase('apgg_group_not_found'), 404));
        }

        return $info;
    }

I'd really appreciate some help here. Probably another dumb play on my part.
 
Your route class should control the setting of the variable. What's in your route class for the 'apgroups' route?

Liam
 
Your route class should control the setting of the variable. What's in your route class for the 'apgroups' route?

Liam
Hey man,

Code:
class Apantic_Groups_Route_PrefixAdmin_Groups
{
    /**
     * Match a specific route for an already matched prefix.
     *
     * @see XenForo_Route_Interface::match()
     */
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        return $router->getRouteMatch('Apantic_Groups_ControllerAdmin_Groups', $routePath, 'apgroups');
    }
}
 
Yeah, you're going to need to implement the buildLink method (in the XenForo_Route_BuilderInterface interface, although it isn't required to implement that interface and most classes don't).

You'll then need to add the resolveActionWithIntegerParam method call to your match method implementation :)

Liam
 
Top Bottom