Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1107301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:55:04+00:00 2026-05-17T01:55:04+00:00

A submitted form on my site returns an array of request data that is

  • 0

A submitted form on my site returns an array of request data that is accessible with

$data = $this->getRequest();

This happens in the controller which gathers the data and then passes this array to my model for placing/updating into the database.

Here is the problem. What if I want to manipulate one of the values in that array? Previously I would extract each value, assigning them to a new array, so I could work on the one I needed. Like so:

$data = $this->getRequest();
$foo['site_id'] = $data->getParam('site_id');
$foo['story'] = htmlentities($data->getParam('story'));

and then I would pass the $foo array to the model for placing/updating into the database.

All I am doing is manipulating that one value (the 'story' param) so it seems like a waste to extract each one and reassign it just so I can do this. Additionally it is less flexible as I have to explicitly access each value by name. It’s nicer to just pass the whole request to the model and then go through getting rid of anything not needed for the database.

How would you do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:55:05+00:00Added an answer on May 17, 2026 at 1:55 am

    Edit again: Looking some more at your question what I am talking about here all goes on in the controller. Where your form`s action will land.

    Well you have a couple of options.

    First of all $_GET is still there in ZF so you could just access it.

    Second there is:

    $myArray = $this->_request->getParams();
    

    or

    $myArray = $this->getRequest()->getParams();
    

    Wich would return all the params in an array instead of one by one.

    Thirdly if the form is posted you have:

    $myArray = $this->_request()->getPost();
    

    Wich works with $this->_request->isPost() wich returns true if some form was posted.

    About accessing all that in your view you could always just in controller:

    $this->view->myArray = $this->_request->getParams();
    

    edit: right I taught you meant the view not the model. I guess I do not understand that part of the question.

    If you want to deal with the post data inside your model just:

    $MyModel = new Model_Mymodels();
    
    $data = $this->_request->getParams();
    $data['story'] = htmlentities($data['story']);
    $myModels->SetItAll($data);
    

    And then inside your model you create the SetItAll() function (with a better name) and deal with it there.

    Edit: oh wait! I get it. You hate sanytising your input one by one with your technique. Well then what I showed you about how to access that data should simplify your life a lot.

    edit:
    There is always the Zend_Form route if the parameters are really coming from a form. You could create code to interface it with your model and abstract all this from the controller. But at the end of the day if you need to do something special to one of your inputs then you have to code it somewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a form inside an <asp:Content> block that is being submitted to a
After my web form is submitted, a regex will be applied to user input
When a web form is submitted and takes the user to another page, it
My form does not go to recipient when submitted! I changed the file mail.tpl.txt
In jQuery, if I assign class=auto_submit_form to a form, it will be submitted whenever
EDIT: I have submitted a bug report and Microsoft have acknowledge that it is
What are the ways to retrieve data submitted to the web server from a
I'm trying to validate that a submitted URL doesn't already exist in the database.
I need to sanitize HTML submitted by the user by closing any open tags
I have a web application (asp.net) where work items are submitted and allocated to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.