Skip to content

Commit

Permalink
Prevent modifying entity type of attributes
Browse files Browse the repository at this point in the history
There is no good reason to allow modifying entity type of
CollectionType and SeriesType attributes.  The only use case would
be to fix careless mistake before the edited attribute gets being
used.  This is safer and simpler to disallow changing it altogether
until finer-grained fields validation is implemented, in particular
checking over related entities and parent/children attributes.
  • Loading branch information
y-van-z committed Mar 1, 2017
1 parent 3db8403 commit cde0df9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions root/admin/attributes/form.tt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
[% ELSE %]
[%~ IF model == "CollectionType" || model == "SeriesType" ~%]
[% form_row_select(r, 'entity_type', add_colon(l('Entity type'))) %]
[%~ IF c.action.name == "edit" ~%]
<script>//<![CDATA[
$(function () {
$('#id-attr\\.entity_type').prop('disabled', true);
$('form[action="[% c.req.uri %]"]').bind('submit', function () {
$('#id-attr\\.entity_type').prop('disabled', false);
});
});
//]]></script>
[%~ END ~%]
[%~ END ~%]

[% form_row_select(r, 'parent_id', add_colon(l('Parent'))) %]
Expand Down

0 comments on commit cde0df9

Please sign in to comment.