1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Missing Argument

Discussion in 'XenForo Development Discussions' started by Gossamer, Jul 11, 2016.

  1. Gossamer

    Gossamer Active Member

    I've put together a simple form to pull up a user. However, I'm getting this error now when attempting to pull up that user:
    This is my ControllerAdmin code:
    PHP:
        public function actionSearch()
        {
            
    $username $this->_input->filterSingle('username'XenForo_Input::STRING);
           
            
    $userModel $this->_getUserModel();
           
            
    $user $userModel->getUserByName($username);
           
            if(!
    $user)
            {
                return 
    $this->responseError(new XenForo_Phrase('no_users_matched_specified_criteria'));
            }
           
            return 
    $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESSXenForo_Link::buildAdminLink('member-awards/user'$user));
          
        }

        public function 
    actionUser($user)
        {
           
            
    $viewParams = array();
           
            return 
    $this->responseView(null'goss_memberawards_user'$viewParams);
        }
    And this is what's in my template:
    Code:
    <xen:title>{xen:phrase goss_member_awards}</xen:title>
    
    <xen:form action="{xen:adminlink member-awards/search}">
        <fieldset>
        <xen:textboxunit label="{xen:phrase user_name}:" name="username" value="{$criteria.username}" type="search" />
        </fieldset>
               
        <xen:submitunit save="{xen:phrase search}" />
    </xen:form>
    Any ideas on what I'm missing?
     
  2. Thomas.B

    Thomas.B Well-Known Member

    The HTTP query parameters are not passed directly to an action method. So in actionUser() you'd need to get them from the $this->_input object such as you get the username parameter in the first method.
     
    Gossamer likes this.
  3. Gossamer

    Gossamer Active Member

    Thanks, that fixed it!

    For anybody curious, this is my new actionUser function:
    PHP:
    public function actionUser()
        {
            
    $userId $this->_input->filterSingle('user_id'XenForo_Input::UINT);
           
            
    $userModel $this->_getUserModel();
            
    $user $userModel->getUserById($userId);
           
            
    $viewParams = array(
                
    'user' => $user
            
    );
           
            return 
    $this->responseView(null'goss_memberawards_user'$viewParams);
        }
     

Share This Page