i am trying to put a single textfield (for doing search) on my app's home page and have it so when i "hit return" the form gets submitted. to start with i am not entirely sure what "return" means? with other apps i have that are like this when i touch inside the text field and the keyboard is brought up; the "return" key is replaced with a "Search" key; which submits the form. in ripple, i assume this is simply hitting CR on the keyboard.
to get the form i create a simple function as:
function mymodule_search_form(form, form_state) {
form.elements.search_terms = {
title:'search',
type:'textfield',
};
return form;
}and then in my page callback and page show functions for my home page i have this:
function mymodule_home_page() {
try {
return {
'search_form': {
'markup': '<div id="search-form">xxx</div>'
}
};
}
catch (error) { console.log('placemarks_accueil_page - ' + error); }
}
function mymodule_home_pageshow() {
$('#search-form').html(drupalgap_get_form('placemarks_search_form'));
}this works fine (placement on the page is odd; but can be fixed with css) but when i type something in the textfield and submit the app crashes with no output to console (i get a wsod). i have a _submit function for the form but it is never hit.
any ideas? perhaps this is just not possible?
Comments
Comment #1
tyler.frankenstein commentedFirst, in your hook_menu() I would suggest this:
...then the code in your pageshow callback won't be needed at all (maybe some other code later though depending on your needs).
Try that first to run through a typical form setup. I'm concerned calling
drupalgap_get_form()from within a pageshow and injecting the form into a container is causing unexpected behavior. Did you have any particular reason(s) for wanting to dynamically inject the form in the page? I'm curious.Next, try changing your form element's type to search instead of textfield.
Comment #2
liquidcms commentedi had a page already defined and then thought adding a form field for search to it would be good. plus i have that form defined and want to add it to various other places.. and, since dgap has all the form render functions.. it seemed like this should work.. and it does for the most part. with a submit button this works.
i use this method in another fashion as well.. with more odd form results.. but i'll post separate issue for that
and i'll try search field.. didnt even see that.
Comment #3
liquidcms commentedhmm. yea, didnt think i missed it, there is no search field listed here: http://www.drupalgap.org/node/274
Comment #4
tyler.frankenstein commentedThe page needs updating, see the theme_* functions on http://api.drupalgap.org/ for the most up to date source. (and you may have to grab the dev snapshot of the bin/drupalgap.js file from the download page).
Comment #5
liquidcms commentedcool. thanks. will check it out.
Comment #6
liquidcms commentedahh, ok, i see a search field adds the magnify glass icon. nice, i was wondering how to add that. works the same as a textfield though for this issue.
Comment #7
tyler.frankenstein commentedThis is now possible, see the snippet here: http://docs.drupalgap.org/7/Forms