[Archivesspace_Users_Group] read-only subrecords

Joshua D. Shaw Joshua.D.Shaw at dartmouth.edu
Wed Nov 21 09:57:15 EST 2018


Try wrapping the form fields in a user_can? statement. Something like


<% if user_can?('administer_system') %>

  <%= form.label_and_textfield "{FIELD_NAME}" %>

<% else %>

  <%= form.label_and_readonly "{FIELD_NAME}" %>

  <%= form.hidden_input("{FIELD_NAME}") %>

<% end %>


Hope that helps!

Joshua


________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Erin Faulder <eef46 at cornell.edu>
Sent: Tuesday, November 20, 2018 4:46 PM
To: archivesspace_users_group at lyralists.lyrasis.org
Cc: Don Smith
Subject: [Archivesspace_Users_Group] read-only subrecords


Cornell is creating a plugin to store a small custom subrecord (so far so good) with the additional requirement that it be read-only from the UI (the data will be imported via other means), so the fields should not be editable from the edit page. Is there a supported way to do this? We’ve tried using the “label_and_readonly” form helper method in my template, and while this does result in the fields being output as read-only labels, they aren’t passed back to the server when one attempts to save the object. We end up getting a database error saying that one of the fields does not have a default value, and inspecting the params object in the log file reveals that my subrecord data is not present at all. Marking the properties as “readonly” in the schema results in the same problem. Using a standard “label_and_textfield” works ok so I don’t know if this is a bug or I’m missing something. This is all on version 2.5.0 at the moment.

Any help/direction is greatly appreciated!

Erin Faulder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20181121/7a3155c2/attachment.html>


More information about the Archivesspace_Users_Group mailing list