CharlieBrady
as usual you pointed me to the right direction
"how to" - maybe someone else is interested
Assume you need one field available to all users (except admin) named NewField which is kept int db Accouns as prop NewProp
First edit the useraccounts file into /etc/e-smith/web/functions
from
...
<field type="text" id="ForwardAddress" validation="emailforward()"
display="display_email_forwarding()"
>
<label>FORWARDING_ADDRESS</label>
</field>
<field type="select" id="VPNClientAccess" options="'yes' => 'YES',
'no' => 'NO'" validation="nonblank" value="get_pptp_value()">
<label>VPN_CLIENT_ACCESS</label>
</field>
...
will become
...
<field type="text" id="ForwardAddress" validation="emailforward()"
display="display_email_forwarding()"
>
<label>FORWARDING_ADDRESS</label>
</field>
<field type="text" id="NewProp"
>
<label>NewField</label>
</field>
<field type="select" id="VPNClientAccess" options="'yes' => 'YES',
'no' => 'NO'" validation="nonblank" value="get_pptp_value()">
<label>VPN_CLIENT_ACCESS</label>
</field>
...
Note
As long as you don't need any restriction in this field should be ok
If you need to have restrictions you should implement an validation sub_procedure
second edit the useraccounts.pm from /usr/lib/perl5/site_perl/esmith/FormMagik/Panel/
(you need to edit in 3 places)
from
....
my $fwd = $cgi->param('ForwardAddress') ?
$cgi->param('ForwardAddress') :
($rec ? ($rec->prop('ForwardAddress')) : '');
my $pptp = $cgi->param('VPNClientAccess') ?
$cgi->param('VPNClientAccess') :
($rec ? ($rec->prop('VPNClientAccess')) : 'no');
# now that we're down with the 411, let's set the values
...
...
$cgi->param(-name=>'ForwardAddress', -value=>$fwd);
$cgi->param(-name=>'VPNClientAccess', -value=>$pptp);
...
...
'ForwardAddress' => $self->{cgi}->param('ForwardAddress'),
'VPNClientAccess'=> $self->{cgi}->param('VPNClientAccess'),
...
will become
....
my $fwd = $cgi->param('ForwardAddress') ?
$cgi->param('ForwardAddress') :
($rec ? ($rec->prop('ForwardAddress')) : '');
my $newvar = $cgi->param('NewProp') ?
$cgi->param('NewProp') :
($rec ? ($rec->prop('NewProp')) : '');
my $pptp = $cgi->param('VPNClientAccess') ?
$cgi->param('VPNClientAccess') :
($rec ? ($rec->prop('VPNClientAccess')) : 'no');
# now that we're down with the 411, let's set the values
...
...
$cgi->param(-name=>'ForwardAddress', -value=>$fwd);
$cgi->param(-name=>'NewProp', -value=>$newvar);
$cgi->param(-name=>'VPNClientAccess', -value=>$pptp);
...
...
'ForwardAddress' => $self->{cgi}->param('ForwardAddress'),
'NewProp' => $self->{cgi}->param('NewProp'),
'VPNClientAccess'=> $self->{cgi}->param('VPNClientAccess'),
...
Note
As long as you don't need to edit the field in this page (for example you'll have another panel for edit) you can omit the last edit
If you opt to omit the last bit you can put any value into the field but it will not be saved (next time you'll access this menu you'll have the initial value)
Question
Do you think this template is ok to be added as "next example" into developer section of wiki, after the CellNumber one ?