<div dir="ltr">Hi,<div><br></div><div>Thanks for your answers.</div><div><br></div><div>Of course, I could do that with relations, but in my specific case I prefer to keep everything in one table (I have some fairly complex triggers to keep versions history and restrict some operations and have no need for separate tables).</div><div><br></div><div>But I'll have a look at the link you provided, and I also found this in the meantime :</div><div><a href="https://woostuff.wordpress.com/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/">https://woostuff.wordpress.com/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/</a><br></div><div><br></div><div>It seems that with this, there's no limit ;)</div><div><br></div><div>Bests,</div><div><br></div><div>Olivier</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-12 8:51 GMT+00:00 Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias.kuhn@gmx.ch" target="_blank">matthias.kuhn@gmx.ch</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div 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 href="http://blog.vitu.ch/10142013-1847/write-your-own-qgis-form-elements" target="_blank">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.<span class=""><br>
    <br>
    CREATE TABLE lots(<br>
      id serial,<br></span>
      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>)<span class="HOEnZb"><font color="#888888"><br>
    <br>
    Matthias</font></span><div><div class="h5"><br>
    <br>
    <div>On 01/11/2015 03:17 PM, Olivier Dalang
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <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></fieldset>
      <br>
      </div></div><span class=""><pre>_______________________________________________
Qgis-user mailing list
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
    </span></blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br></blockquote></div><br></div>