my $order = time;
my @values;
+ my %value_keys;
for my $value_key (sort grep /^value/, keys %option_fields) {
my ($value) = $cgi->param($value_key);
if (defined $value && $value =~ /\S/) {
display_order => $order,
);
push @values, $entry;
+ $value_keys{$value_key} = $entry;
++$order;
}
}
+ my $def = $cgi->param("default");
+ if ($def && $value_keys{$def}) {
+ $option->set_default_value($value_keys{$def}->id);
+ $option->save;
+ }
$req->is_ajax
and return $req->json_content
</div>
<:.end if:>
<:.if request.user_can("bse_edit_prodopt_add", article) :>
+<:.define addform_value_entry:>
+<div class="valueentry<:= index mod 2 == 0 ? "" : " odd":>"><span><input type="text" name="value<:= index :>" value="<:= cgi.param("value" _ index) :>" maxlength="255" class="editor_field" title="Enter some values here" /></span><span><input type="radio" name="default" value="value<:= index :>"></span><span><:.call "error_img", field: "value" _ index:></span></div>
+<:.end define:>
+<:.define addform_value_head:>
+<div class="valueentry"><span>Values</span><span>Default</span></div>
+<:.end define:>
+<:include admin/edit_prodopt_custom.tmpl optional:>
<div id="addoptionform" class="prodopt">
<form action="<:script:>" method="post">
<:csrfp admin_add_option hidden:>
<input type="hidden" name="id" value="<:= article.id:>" />
<div class="prodoptmenu">Option: <input type="text" name="name" value="<:= cgi.param("name") :>" maxlength="255" class="editor_field" title="Enter the name of your new option here" /><:.call "error_img", field: "name":><input type="submit" name="a_add_option" value="Add New Option" class="editor_ok_button" /></div>
<div class="prodoptvalues">
-<div class="valueentry"><input type="text" name="value1" value="<:= cgi.param("value1") :>" maxlength="255" class="editor_field" title="Enter some values here" /><:.call "error_img", field: "value1":></div>
-<div class="valueentry odd"><input type="text" name="value2" value="<:= cgi.param("value2") :>" maxlength="255" class="editor_field" /><:.call "error_img", field: "value2":></div>
-<div class="valueentry"><input type="text" name="value3" value="<:= cgi.param("value3") :>" maxlength="255" class="editor_field" /><:.call "error_img", field: "value3" :></div>
-<div class="valueentry odd"><input type="text" name="value4" value="<:= cgi.param("value4") :>" maxlength="255" class="editor_field" /><:.call "error_img", field: "value4":></div>
-<div class="valueentry"><input type="text" name="value5" value="<:= cgi.param("value5") :>" maxlength="255" class="editor_field" /><:.call "error_img", field: "value5":></div>
+<:.call "addform_value_head":>
+<:.for index in [ 1 .. 5 ] :>
+<:.call "addform_value_entry" :>
+<:.end for:>
</div>
</form>
</div>