You are not logged in.
On my application I have a HTML form with select2:
<select class="form-control select2" id="Contacts" name="Contacts" multiple="multiple" data-placeholder="" style="width: 100%;" value="{{Project.Contacts}}">
{{#Contacts}}
<option value="{{{ID}}}" {{{Status}}}>{{{Ident}}}</option>
{{/Contacts}}
</select>
The user can select more option so when the user submit the form I have a URI like this:
...&Contacts=10&Contacts=11...
How can I handle this on MVCViewModel?
I should have an array on MVCViewModel so I have define a variant and try with:
with _Safe(Contacts)^ do
for j := 0 to Count-1 do
begin
if VariantToInt64(Values[j], ido) then
project.DynArray('Contacts').Add(ido);
end;
but NOT work.
I have the feeling that the framework with considering this possibility.
In fact I think it use only last value of Contacts variable (11 on my example).
Am I wrong?
Note I have also try to use "name="Contacts[]" on form.
Offline
One variable name in URL = one variable value on server side...
This was as designed, and there is no such feature as "automatic array".
This "multiple" tag is indeed not handled yet.
Offline
This "multiple" tag is indeed not handled yet.
Is there an alternative way to handle multiple selection input of html form?
On my application should have many multiselection input.
Offline
You can access raw input parameters:
var
i: Integer;
LContacts: TRawUTF8List;
begin
with CurrentServiceContext.Request do
begin
for i := 0 to (Length(InputPairs) shr 1) - 1 do
begin
if InputPairs[i * 2] = 'Contacts' then
begin
LContacts.Add(InputPairs[i * 2 + 1]);
end;
end;
end;
end;
Offline
You can access raw input parameters
Thanks for you suggestion.
Offline