ADR|NOTE)
printf '[h3 %s]' "$(l10n "$item")"
seq 1 $cnt |while read c; do
- printf '[checkbox "%s_delete" "%i" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
+ printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
"$item" $c "$item" $c "$item" $c "$(l10n delete)"
printf '<textarea class="item %s" name="%s">%s</textarea>' \
"$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)"
;;
TEL) printf '[h3 %s]' "$(l10n "$item")"
seq 1 $cnt |while read c; do
- printf '[checkbox "%s_delete" "%i" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
+ printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
"$item" $c "$item" $c "$item" $c "$(l10n delete)"
teltype="$(pdi_attrib "$card" TEL $c TYPE)"
printf '[select .item .teltype name="teltype"
;;
*)printf '[h3 %s]' "$(l10n "$item")"
seq 1 $cnt |while read c; do
- printf '[checkbox "%s_delete" "%i" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
+ printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
"$item" $c "$item" $c "$item" $c "$(l10n delete)"
printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \
"$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")"
esac
done; done
+# delete fields, first mark for deletion using delete_key
+# this way the field enumeration is preserved during the process
+# finally filter marked lines
+delete_key="$(randomid)"
+for delete in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*_delete_[0-9]+'); do
+ f="${delete%%_*}"; c="${delete##*_}";
+ [ "$(POST "$delete")" = "true" ] && vcf="$(pdi_update_value "$vcf" "$f" "$c" "delete=${delete_key}")"
+done
+vcf="$(printf '%s\n' "$vcf" |sed -E "/^[^:]+:delete=${delete_key}\$/d")"
+
if [ "$action" = addfield ]; then
vcf="$(pdi_update_value "$vcf" "$newfield" $(( $(pdi_count "$vcf" "$newfield") + 1 )) '')"
fi