How create a Select Field (multiple) in Admin (article_main)

Hello all,
I try to add a select field (multiple) in the admin area of oxid for article_main.
It should be possible to select multiple authors from that list.
Somehow the selection should be saved to the database.
How do I start?
Can I create such Lists in the Backend or do I have to write a module?
Thanks in advance,
Florian

you have to write your field in /out/admin/tpl/article_main.tpl look at some other fields they have the same structure:


<input type="radio" name="editval[oxarticles__yyy]" value="author 1"/>
<input type="radio" name="editval[oxarticles__yyy]" value="author 2"/>
<input type="radio" name="editval[oxarticles__yyy]" value="author 3"/>

you can no define yyy as the database field where the Author should be written to.
and that is all. rest Oxid takes care off.

regards

Rafael

e: select is of course possible too:


<select name="editval[oxarticles__yyy]">
<option value="author 1">Author 1</option>
<option value="author 2">Author 2</option>
<option value="author 3">Author 3</option>
</select>

Thank you Rafael! that works fine if I just wanted to store a single value. But it should be possible to select multiple authors in that select field.
For me it would be ok to store the ids of the selected author in a single column in the database like “1,3,5”. But I have no clue how to do that.
Thanks,
Florian

Hmm don’t know if oxid is as smart as i am :wink: but you could try to use arrays for that. If i were oxid i would serialize the array and store it but i never tried ist.


<input type="check" name="editval[oxarticles__yyy][0]" value="author 1"/>
<input type="check" name="editval[oxarticles__yyy][1]" value="author 2"/>
<input type="check" name="editval[oxarticles__yyy][2]" value="author 3"/>

Maybe this works. if not you can add a bit JS and a hidden field with the value for the database. Somthing like onchange etc.

Regards

Rafael

Hey Rafael!
thank you! the javascript solution worked quite well.
Regards,
Florian