Need another pair of eyes - page callback & form
I've been staring at this an hour now...time go ask for help! I have two reports. The menu entries are below. Each works. They are identical other than name. At the top of each, I provide a button to request a CSV. The report's callback checks for the get value associated with the button. The buttons are each submits. The action for the form in each report is the final part of the callback path. Report 1 successfully returns to the callback function for it. Report 2, when the button is clicked, just spins and spins. If I change the action in report 2 to 'customers'... it finds its way to that callback function, but can't seem to find its own. Of course, the callback function is found when simply clicking on the menu link for the report...so I'm thinking it's the form action...but can't figure it out. function my_reports_menu() { global $user; $items = array(); $items['admin/store/reports/my/customer'] = array( 'title' => 'Customers', 'description' => 'Customer name and address list', 'page callback' => 'my_reports_customers', 'access arguments' => array('view reports'), 'type' => MENU_NORMAL_ITEM, 'weight' => 10, ); $items['admin/store/reports/my/orders'] = array( 'title' => 'Orders today', 'description' => 'Orders placed today', 'page callback' => 'my_reports_orders', 'access arguments' => array('view reports'), 'type' => MENU_NORMAL_ITEM, 'weight' => 10, ); } From report that doesn't work $output .= '<div><form id="csv" action="orders" method="get" /><input type="hidden" name="csv" value="true" /><input type="submit" value="CSV" style="background-color: gold" /></form></div>'; The one that does work ...and if the action above is changed to 'customer' as below, it gets processed $output .= '<div><form id="csv" action="customer" method="get" /><input type="hidden" name="csv" value="true" /><input type="submit" value="CSV" style="background-color: gold" /></form></div>';
Are both of these forms on the same page? If so, they can't have the same id. -- John Fiala www.jcfiala.net
On 1/11/2010 3:50 PM, John Fiala wrote:
Are both of these forms on the same page?
If so, they can't have the same id.
No, they both come from the same module, but each is the top of a separate report, never on the screen at the same time.
'title' => 'Orders today', $output .= '<div><form id="csv" action="orders" method="get" /><input type="hidden" name="csv" value="true" /><input type="submit" value="CSV" style="background-color: gold" /></form></div>'; The action="Orders today" is the only thing I can see. The other one has the Customer with 'title' => 'Customers',. If that makes any sense.
On 1/11/2010 4:30 PM, Cory Gilliam wrote:
'title' => 'Orders today', $output .= '<div><form id="csv" action="orders" method="get" /><input type="hidden" name="csv" value="true" /><input type="submit" value="CSV" style="background-color: gold" /></form></div>';
The action="Orders today" is the only thing I can see. The other one has the Customer with 'title' => 'Customers',. If that makes any sense. the action on the other one is actually 'customer' - singular, so different than the title too
I keep thinking it -has- to be the action, because the original menu callback works and the action does not. I can't remember how the form action (just the one word) ties back to the callback... in terms of it not having anything but the final segment of the path...and because I can't remember...I'm thinking that's where the problem is.
Can I ask why you aren't using formsAPI so that you could know that all that wasn't an issue and just route the submit to a callback and a #redirect? Seems like in this case it would make your troubleshooting a world easier. -S On Jan 11, 2010, at 4:45 PM, Jeff Greenberg wrote:
I keep thinking it -has- to be the action, because the original menu callback works and the action does not. I can't remember how the form action (just the one word) ties back to the callback... in terms of it not having anything but the final segment of the path...and because I can't remember...I'm thinking that's where the problem is.
On 1/11/2010 4:56 PM, Sam Tresler wrote:
Can I ask why you aren't using formsAPI so that you could know that all that wasn't an issue and just route the submit to a callback and a #redirect? Seems like in this case it would make your troubleshooting a world easier.
I was just lazy. The form consists of the submit button. I thought it would be overkill.
Jeff Greenberg wrote:
I keep thinking it -has- to be the action, because the original menu callback works and the action does not. I can't remember how the form action (just the one word) ties back to the callback... in terms of it not having anything but the final segment of the path...and because I can't remember...I'm thinking that's where the problem is.
I agree with this. You should try to make the /action a fully qualified URL rather than a relative URL.
Try: $output .= '<div><form id="csv" action="'.url('admin/store/reports/my/customer').'" method="get" /><input type="hidden" name="csv" value="true" /><input type="submit" value="CSV" style="background-color: gold" /></form></div>'; Jamie Holly http://www.intoxination.net http://www.hollyit.net On 1/11/2010 4:45 PM, Jeff Greenberg wrote:
I keep thinking it -has- to be the action, because the original menu callback works and the action does not. I can't remember how the form action (just the one word) ties back to the callback... in terms of it not having anything but the final segment of the path...and because I can't remember...I'm thinking that's where the problem is.
What it turned out to be, after trying everything, was a combination of the url needing to be qualified, and apparently a collision with the original callback (I presume) existing somewhere else. When changed it from orders to orders_details in the callback and the action, it worked. Very odd that the action would not work with the original callback (even when the url became qualified) but the menu link would! Thanks all!
participants (6)
-
Cory Gilliam -
Earl Miles -
Jamie Holly -
Jeff Greenberg -
John Fiala -
Sam Tresler