I need to add items to a dropdown element defined in Forms, I have tried it with JQuery append method inside script tag (.volt files) but it won't work, is there any way to do this?
<field>
<id>general.test</id>
<label>Test Dropdown</label>
<type>dropdown</type>
</field>
@mimugmail Please have a look here
I'm note a core dev, for me it seems you have to choose the correct FieldType in Model. Which objects do you need to be dynamically loaded? Interfaces? Otherwise you have to add dialog tab and let the use add them (like Prefix-Lists in FRR->BGP)
I think there is two ways to append dynamically to dropdown, Controller and View, I've tested view already and not working:
$this_item.append($("<option value=''>text</option>"))
But I don't know how to append a item inside controller. may appending to model updates view which I don't know how to do that.
The items I want to load is Users in freeradius. actually I need a dropdown to select freeradius defined users (Username(s)).
Go to FRR Plugin source, BGP controller, look at ModelRelationField. That's exactly what you want ...
I cannot got it to work, the line:
in my case source is in another model, it will not works.
You said you need FreeRadius Users as source, so where is the problem?
If you exactly tell us what you want to achieve we can help you for sure :)
@mimugmail Thank you!
I need to load users defined in Freeradius users section, so I have defined a dropdown in view and a model and controller respectively,
Controller:
<field>
<id>test.user</id>
<label>User Name</label>
<type>dropdown</type>
</field>
Model:
<model>
<mount>//OPNsense/freeradius/test</mount>
<items>
<tests>
<test type="ArrayField">
<enabled type="BooleanField">
<default>1</default>
<Required>Y</Required>
</enabled>
<user type="ModelRelationField">
<Model>
<template>
<source>OPNsense.freeradius.user</source>
<items>users.user</items>
<display>username</display>
<group>username</group>
</template>
</Model>
<Required>Y</Required>
</user>
</test>
</tests>
</items>
</model>
Please check for correct usage of upper/lower-case.
This one took me a complete day:
Actually that's the problem, <source>OPNsense.freeradius.user</source> is case sensitive, and after the case correction dropdown shows the users, its resolved, thanks for your cooperation.
Welcome to the Team. :)
nice, thanks guys! 鉂わ笍
@mimugmail @fichtner Question: build times for make plugins command are too long when working on just a plugin, how to make a plugin itself without involve in making all plugins?
opnsense-code plugins
cd /usr/plugins
Then your directory If plugin, do your changes and make upgrade at plugin level like www/c-icap
@mimugmail Like this?
$ cd /usr/plugins/net/freeradius
$ # make changes
$ make upgrade
Yep
@mimugmail Thanks a lot, you saved me!
There are some guides by example related to plugin development .. bit outdated but development it too fast :)
@mimugmail Hello, Another question please, I want to place html elements horizontal, the default value with base_dialogue or other forms is vertical.
The following snippet is place elements in vertical, I want that to be horizontal.
<field>
<id>example.element1</id>
<label>Element 1</label>
<type>text</type>
</field>
<field>
<id>example.element2</id>
<label>Element 2</label>
<type>dropdown</type>
</field>
<field>
<id>example.element3</id>
<label>Element 3</label>
<type>dropdown</type>
</field>
I'm not the html guy, sorry. @AdSchellevis any ideas?
it's better to keep it simple than ask for other people's time. we don't support different layouts of forms.
@fichtner I'm sorry for other people's time, but I think this is major requirement, sometimes needs to layout elements horizontaly due to user experiences.
I have opened an issue.
Most helpful comment
Welcome to the Team. :)