Timeline for How to execute Drupal form without waiting? Ajax? Jquery?
Current License: CC BY-SA 3.0
22 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Sep 17, 2014 at 17:28 | history | mod moved comments to chat | |||
S Sep 17, 2014 at 17:28 | comment | added | mpdonadio♦ | Comments are not for extended discussion; this conversation has been moved to chat. | |
Sep 17, 2014 at 4:11 | history | edited | 2pha | CC BY-SA 3.0 |
added 21 characters in body
|
Sep 17, 2014 at 4:10 | comment | added | 2pha |
Sorry, the function does need to return 'form' and you must remove the menu_get_object() from the submit function and use an alternative method to get the node. As you now have access to the node id in the submit fuction, you can use node_load()
|
|
Sep 16, 2014 at 11:32 | comment | added | Sasha | If I remove return $form; part then the whole block returns with empty content. | |
Sep 16, 2014 at 11:24 | comment | added | Sasha | I've added another Edit3 with the html code of the whole block. Maybe I am doing something wrong with 'wrapper' => 'block-server-server-status'? | |
Sep 16, 2014 at 11:17 | comment | added | Sasha | I did not as it seems to be there in your code too. I've updated the whole peas under "Edit2", could you please take a look at it? Thanks! | |
Sep 16, 2014 at 11:11 | comment | added | 2pha |
did you remove the call to menu_get_object() in the submit function?
|
|
Sep 16, 2014 at 11:08 | comment | added | Sasha | Unfortunately, it is still giving: An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /system/ajax StatusText: Service unavailable (with message) ResponseText: #0 entity_extract_ids(node, stdClass Object ([field_status_code] => etc .... :( | |
Sep 16, 2014 at 11:00 | comment | added | 2pha |
I have updated the answer showing how to add a hidden field to the form. This value should now be available in the submit handler. This should allow you to load the node without using the menu_get_object() function in the submit.
|
|
Sep 16, 2014 at 10:59 | history | edited | 2pha | CC BY-SA 3.0 |
added example of node id in hidden field
|
Sep 16, 2014 at 10:44 | comment | added | Sasha | sorry but it is not so obvious to me. Looking at my code above what should be another form look like? I really do not understand. Thanks! | |
Sep 16, 2014 at 4:00 | comment | added | 2pha | ?.... I did not mean to add type=>hidden on your submit button, I mean create another form element of type=>hidden and give it a default value | |
Sep 15, 2014 at 22:23 | comment | added | Sasha | '#type'=>'hidden' is hiding my submission button. With only 'default_value'=>$node->nid left it still gives the error. Please see the edit section above, as it is not convenient to add code in comments. Thanks! | |
Sep 15, 2014 at 12:15 | comment | added | 2pha |
same way as you added the submit button except '#type"=>'hidden' , and 'default_value'=>node->nid
|
|
Sep 15, 2014 at 10:46 | comment | added | Sasha | The form is displayed in a block, which is placed on a node page using Display Suite module. But how exactly I should add a hidden element with node id? So confusing... | |
Sep 15, 2014 at 10:39 | comment | added | 2pha | It would depend on where your form is being displayed. Is the form being displayed on a node page? If so, you could add a hidden form element containing the node id, then it should be available in the submit function. | |
Sep 15, 2014 at 8:32 | comment | added | Sasha | Could you please give some specific examples of how "to send an argument in the url that will allow you to load the appropriate node" as I am unfortunately not that much experienced? Thanks! | |
Sep 15, 2014 at 8:11 | comment | added | 2pha |
Then I suspect your problem is with your call to menu_get_object as the current path in the ajax request is system/ajax so `menu_get_item' will not work in an ajax call. You are probably going to have to send an argument in the url that will allow you to load the appropriate node.
|
|
Sep 15, 2014 at 4:47 | comment | added | Sasha | The form had already been nested in div with id "block-server-server-status". Replacing 'wrapper' => 'status-form-wrapper' in your suggested code with 'wrapper' => 'block-server-server-status', is giving: An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /system/ajax StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7729 of /home/dev/public_html/includes/common.inc). | |
Sep 15, 2014 at 4:41 | comment | added | Sasha | thanks for your help. Unfortunately lines: $form['prefix'] = '<div id="status-form-wrapper">'; $form['suffix'] = '</div>'; give WSOD. Without them: An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /system/ajax StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7729 of /home/dev/public_html/includes/common.inc). | |
Sep 15, 2014 at 4:03 | history | answered | 2pha | CC BY-SA 3.0 |