Hello everyone, I explain what I would like to do:
I have two modules, in Module A I have a list that varies and increases of this type
Name id
France 1
Italy 2
USA 1
Switzerland 2
…
Now Module B is a subpanel of another module that has to be set according to Module A:
If the third module is referred to id 1, we will have as header:
France USA
if the third module is referred to id 2, we will have as header:
USA Switzerland
Do you have any suggestions of how to implement this idea?
Thanks
Hi @p.konetskiy,
I don’t know at the beginning how many fields I need, how can I create a dropdown that in one case can contain one value, in another 2 values or 3, 4…?
I don’t know your end target. I see some variants:
use special module for it and write custom function. look at the function get_user_array in the file include/utils.php, it create dropdown users in filter of each modules.
modify dynamicly dropdown in backend when a record is saving.
modify dynamicly dropdown in frontend.
I do not exclude that there could be a simpler option.
Sorry for only responding now, but in the meantime my PC stopped working and is now in service and I’m with a temporary one.
I try to explain better my target:
In the Module A (which is a subpanel of another module) I create a list
I tried the code you proposed, it is ok if I have already defined in Module B the fields via Studio, so I should have already created the fields field1… fieldN
and in this way I’m going to fill the existing fields with those of Module A.
So I should first create the fields field1… fieldN, but I don’t know how to do it in code, I couldn’t find anything on the net.
But I only know those fields after creating them in Module A. That’s why I think they have to be defined in Vardefs first, so I tried something like this:
but it doesn’t work is there any way to do it? Also I think I should change the subpanel layout too, but again I don’t know how to get there from code
yes, I get that field1…it was an example, I just picked it up. it’s really your point 3 that I’m missing.
How do I create from code those fields that I only know about when I create them in Module A?
Something like this:
$beanModuleB= new ModuleB();
$beanModuleB->addfield(field1);
…
Sorry we don’t understand each other. I don’t suggest to create field dynamically. I think that you take correct records from ModuleA and copy the values of some fields to ModuleB. Main task is find required entries in ModuleA. You can create the fieldsin Studio.
That’s the point, I have to create fields dynamically because I don’t know before what fields I need, I know them only after inserting them in Module A, that’s why I wanted a way to create, via code, the fields. If you have a better idea to do what I need I’m listening.
Another way would be to create a “Type” field in Module B, which contains the values of the “Name” field in Module B:
I enter in Module A
USA
Italy
France
and in Module B in the Type field: USA;Italy;France
but then I don’t know how to explode these values so that in the subpanel (Module B) has as header:
As per the screenshots above, what I want is to enter the data in Module A and based on that create the fields in Module B. The ideas I’ve come up with are:
create dynamic fields in Module B via code.
create a field in Module B that contains the values of Module A:
if in Module A I have
Name id_factory
US 1
Italy 1
France 2
In the Type field of Module B I will have:
USA;Italy (if the detail is referred to id_factory 1)
France (if the detail is referred to id_catory 2)
In both cases I don’t know how to do it.
If you have other suggestions…
so that in each column can be inserted the required data
So the Name field of Module B must be split, it’s ok to insert the content in the Name field, but then, on screen they must appear on different columns, so that the data can be inserted, but formally only one field is used.
I don’t know if I can explain myself, I know it’s a bit convoluted, but I can’t do otherwise
Sorry I can’t help you because i think that you should change vision to the task. If data doesn’t have logical structure then you should change the rules to work with them. It’s my opinion only. I don’t know your business and I can’t suggest a variant.
Excuse me @p.konetskiy, what if instead of creating dynamic fields, I create 3 fixed fields in Module B via Studio like Field1, Field2, Field3 and then change the subpanel header depending on id_factory of Module A?
That is:
Module A
Name id_factory
US 1
Italy 1
Module B Field1 Field2
then I change via code the header of Module B which becomes: Usa(Field1) Italy(Field2)
is it possible to do something like this? If yes, how?