Equivalent of URL helper inside Zend Form - zend-framework

I have a zend form, and I need to provide a dynamic link on the form. ie. user tries to select from drop-down -> if desired option not present, click on the adjacent link to open another form where they can add the option. The link will be dynamic because I want to post some data from the current form using GET (the country and region already selected for example).
How can I do this?

Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, $name, $reset, $encode)
IE:
Zend_Controller_Front::getInstance()->getRouter()->assemble(array('controller' => 'index', 'action' => 'index'), null, true)
Same as in the Zend_View_Helper_Url...

You could do this client-side using javascript/AJAX - detect clicking on the link, collect form data and continue to a different page. If you need a fancy URL of the other page, you'd have to make an AJAX call to the server to get the fancy URL based on the form parameters,
or
make the link a submit button actually, process the form server-side (detecting that the special submit button was clicked; example here) and do a redirect to your other page.
As for rendering the link next to a Zend_Form_Element, you can do this in a few ways, one of them would be placing it in the label or description (setLabel(), setDescription()) while making sure to set the escape parameter of the decorator to false (example here)

Related

Pass/give something other than a form to the POST request

I'm doing a form where when you select an option (with the and tag), a text below the form change according to the choice.
I would like to have this text along with my form data when send to a POST request.
I'm using Express and EJS.
Btw I also have GET parameters and would like the same thing as the text, any thoughts ?
Can you help me please ?
Thanks !
Whatever code you have that changes the text according to your choice, can also set a hidden form value in your form to the same value. That hidden form value will not display to the end user in the browser, but will be sent with the form as part of the POST (as another value of the form).
Here's an example of a hidden form element from that previous linked reference:
<input type="hidden" id="custId" name="custId" value="3487">
If this is inside your <form>, you can then change it with your Javascript to whatever you want it to and it will be automatically sent to your server as one of your form values when the form is POSTed to your server, but won't be shown to the user because of the type="hidden".

create a from and show entered details in another page in orchard cms

just created a from using "custom form" with input fields like - "Title", "Caption", "Alternate Text", and a button called "Submit". After submit i need to show the entered input fields as an output in another page. How can i achieve this.
Pls guide me with step by step solution. I am not a developer, Im just a designer
So, you created a custom type and added those fields.
Then created a custom form with this type.
You can configure the form to redirect after submit thanks to an textbox that allows to use Tokens, i.e dynamic information retrieved by the content.
Thanks to this, you should be able to redirect to the display url of the content.
To display the output the way you want in another page, you need to make an override of your content in your theme.
You can enable the 'Shape tracing' feature to generate this alternate view of your content and then modify it as you want.

Redirect to another HAML page after clicking link

After clicking a link, I want to redirect the user to another HAML view and send some local data along with it. How do I do this?
If I get your question right, you want to display a page with a link. If a user clicks the link he gets forwarded to the link target and you want to fetch information from the client when the request hits in.
If so, it depends what kind of information you want to send. If you have the information on server side when rendering the page, you would put them straight as query string parameters to the target url of the link, with HAML like this:
%a{ :href => "/target?var1=#{#var_x}&var2=#{#var_y}", :title => "your link" }
would become in HTML:
your link
If the user follows the link, you would fetch the information in your Sinatra route like this:
get "/target" do
puts params[:var1] # => value_x
puts params[:var2] # => value_y
end

How do I make a link that pre-fills a form checkbox?

I have a page called contact.htm with a working form. One of the checkbox fields on the form is named Garden (so either it is checked or not when using the form).
I have another page that I want to link to my form page, so that if a user clicks a particular link, they are sent to the form page and the field Garden is pre-clicked.
I have not been able to do this though I have tried several methods...such as:
a href="contact.htm?checkbox=Garden,on" or
a href="contact.htm?checkbox=Garden,checked" or
a href="contact.htm?input type="checkbox" name="Garden" value="checked", and some others.
I would appreciate any help.
You'll need to use JavaScript on the target webpage to process the argument and fill the values in. There is no automatic way of doing this just by URL.
This link shows how to retrieve URL arguments from JavaScript. From there, it's a matter of using standard JavaScript or JQuery to fill the values in.

Getting form values from outside the form in jsp?

I just want to know if this is possible, let say I have form of a search bar that has a dropdown list that applies to the search with it on the front page and I have links on the side of recent search words which is outside of the form and I want to get the currently selected dropdown value from outside the form is this possible?
I'm using spring tool suite.
You could use javascript to copy the value from the drop-down into a hidden input field when the user presses submit. In jquery you'd do something like this: $('#mySubmitButton').click(copyFn);, where copyFn is implemented to do the copy and perform the submit afterwards (although you'll have to stop the form automatically submitting in the first place, this isn't difficult).
Alternatively, you could just widen the scope of the form to encompass the drop-down.