<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Olivier,<br>
<br>
There is some support for this in the value relation widget. If you
allow multiple selections, it will make use of the array notation,
storing multiple foreign keys ( { fk1, fk2, fk3 } ).<br>
<br>
If you want to get further support for this, you could write your
own form elements which is possible for some time (although I
haven't seen it widely used).<br>
<a class="moz-txt-link-freetext" href="http://blog.vitu.ch/10142013-1847/write-your-own-qgis-form-elements">http://blog.vitu.ch/10142013-1847/write-your-own-qgis-form-elements</a><br>
<br>
For your last use-case "same number of items" you should consider to
normalize your database and and have two tables linked with a
foreign key.<br>
<br>
CREATE TABLE lots(<br>
id serial,<br>
common_data text<br>
)<br>
<br>
CREATE TABLE person(<br>
id serial,<span style="font-family:monospace,monospace"><br>
first_names text</span><span
style="font-family:monospace,monospace">,<br>
</span><span style="font-family:monospace,monospace"> last_names
text</span><span style="font-family:monospace,monospace">,<br>
</span><span style="font-family:monospace,monospace"> age int,<br>
group integer REFERENCES lots(id)<br>
</span>)<br>
<br>
Matthias<br>
<br>
<div class="moz-cite-prefix">On 01/11/2015 03:17 PM, Olivier Dalang
wrote:<br>
</div>
<blockquote
cite="mid:CAExk7p17pP0_Ag8EbdjuB=zNTSp4fjWNcL1_4N9QmtB5YU=SYw@mail.gmail.com"
type="cite">
<div dir="ltr">Hi !
<div><br>
</div>
<div>Postgres' arrays are a great feature. They allow store
several values in one field :</div>
<div><br>
</div>
<div><font face="monospace, monospace">CREATE TABLE lots(</font></div>
<div><font face="monospace, monospace"> id serial,</font></div>
<div><font face="monospace, monospace"> owners text[]</font></div>
<div><font face="monospace, monospace">);</font></div>
<div><font face="monospace, monospace">INSERT INTO lots(owners)
VALUES( ARRAY['john','mike','jenny'</font><span
style="font-family:monospace,monospace">] );</span></div>
<div><br>
</div>
<div><font face="arial, helvetica, sans-serif">But is there a
way to edit this cleanly in QGIS with the forms ?</font></div>
<div><font face="arial, helvetica, sans-serif">Natively, the
form widget will be a plain text input, and the value will
display like this</font></div>
<div><font face="monospace, monospace">{"john","mike","jenny"}</font></div>
This is more or less usable for text fields, but not really
clean, since the user needs to escape some characters, and it's
not very readable. But then it's impossible to use with other
widgets (checkbox, range, etc.)
<div><br>
<div>I'd love to have a dynamic input where the user could add
and remove fields, and where QGIS widget types could be
used.</div>
</div>
<div><br>
</div>
<div>Actually, I'd even need a form where I'd have the same
number of items for several arrays, and where adding/removing
an item would work on several field at once, to work on a
table like this :</div>
<div>
<div><font face="monospace, monospace">CREATE TABLE lots(</font></div>
<div><font face="monospace, monospace"> id serial,</font></div>
<span style="font-family:monospace,monospace"> first_names
text[]</span><span style="font-family:monospace,monospace">,<br>
</span><span style="font-family:monospace,monospace">
last_names text[]</span><span
style="font-family:monospace,monospace">,<br>
</span><span style="font-family:monospace,monospace"> age
int[]</span>
<div><font face="monospace, monospace">);</font></div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
<div>
<div>
<div><br>
</div>
<div>Is there a way to do it ?</div>
<div>Maybe with python ?</div>
<div>Has anyone of you already done this and would agree to
share ?</div>
</div>
<div>Any pointer in the right direction would be very welcome
!</div>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">Thanks a lot in
advance,</font></div>
<div><br>
</div>
<div>
<div dir="ltr">
<div class="gmail_extra"><br clear="all">
<div>
<div dir="ltr">
<div style="font-family:arial;font-size:small">Olivier</div>
</div>
</div>
</div>
</div>
<br>
</div>
<div><font face="monospace, monospace"><br>
</font></div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<br>
</body>
</html>