I have a form to create an ingestion, for a diet module I'm working on. An ingestion is a group of meals (first course, second, drinks....) and I use the ahah helper module to build up a meal list subform within the ingestion form. It works great as long as I use textfields elements for the list of meals (I use the replace behavior to update the list with a new meal chosen with an autocomplete field). However, it would be great to have a list of items elements instead of textfields elements, because once a meal is chosen and added to the list I don't want the user to be able to change it (only delete). But the ahah is not working if I change the textfield element for an item element. Even if I set the meal textfield as disabled the ahah fails. Is there any structural reason, in the ahah helper module, for that?
Comments
Comment #1
wim leersThe actual question is this part:
So you are changing
#type, right?Basically something like:
Right? I don't know by heart why this wouldn't work. Could you maybe post a piece of sample code? Then I could start working and potentially debugging from that.
Comment #2
robertgarrigos commentedthis is the menu entry:
and this is the callback function to build up the form:
These are the helpers functions for the previous callback function:
I'm sure this code could be better but this is actually working. And indeed, by only changing the type of the element $form[$key]['m'] to item the list doesn't work. What I've seen is that ,when doing that change, the element $form_state['values']['meal_list'] doesn't get posted, thus the if section
doesn't get printed. Then, only the last meal is been shown in the list.
Can you see what's wrong? thanks very much for your help.
Comment #3
robertgarrigos commentedMore over: I use a theme function, based on theme_texfield, to show an element in the list in different ways:
There are three lines which allow you to show the item in three different ways:
Whenever you choose to show only the element value or a disabled textfield the meals list only show the last element.
Comment #4
wim leersPlease update to version 2 and check if this problem persists.
Comment #5
Rok Žlender commentedNo activity for 2 years closing.