Farzan Najipour
Farzan Najipour

Reputation: 2503

passing input value of form in zend framework

I want to pass input variable to a controller and a action , I've tried here but it cannot specify phone number which user already inserted .

<form class= "search-phone" action="" method="get">
        <p>phone number:</p>
             <input type="text" name="phone" />
            <a class="button-link" href="<?php echo $this->url(
            array(
                'controller' => 'books',
                'action'     => 'search',
                 'search_id' => $'_GET[phone]'
            ),
            'default',
            true) ?>">search
        </a>

</form>

Upvotes: 0

Views: 424

Answers (1)

indubitablee
indubitablee

Reputation: 8206

You're supposed to use the <form> element's action to submit the contents of the input's within the form (unless you're using ajax or are in need of a special interruption/task before the submit of the form). You're anchor link is just directing you to a url. And your form should be posting as the method, not getting. The form element should look something like this:

<form class="search-phone" action="controller_name/action_name/or_however_you_get_to_your_action" method="POST">

And then you have to add a submit button. Then in your action in your controller, you want to get whatever is posted, something like this:

action_name() {
    $phone = $_POST['phone']; 
}

where 'phone' corresponds to the element's value whose name is "phone".

hoep this helps

Upvotes: 1

Related Questions