btech
Total posts: 30
15 Март 2014 12:43

hi

i have created cobalt type and created number of fields for this type

there is a field status having options (public, private)

if a registered user comes and submit new record by selecting status as private

i want to restrict public users to view this record.

using emerals 9 how can i create/define rule for that

thanks

Последние изменения: 17 Март 2014


Sergey
Total posts: 13,748
17 Март 2014 03:37

This is not related to Emearld 9. It is only rights management. Here is what I did тку on this forum.

  1. In form template paramters turn of accesses field.
  2. In custom template add this element to the form
<div class="control-group">
    <label id="category-lbl" for="category" class="control-label"></label>
    <div class="controls">
        <label class="checkbox">
            inpu type="checkbox" id="privat-chk" item->access == 3 ? 'checked' : null); ?>/> Private 
            <small>If checked, this topic will be visible only for official support staff members.</small>
            <input type="hidden" id="jform_access" name="jform[access]" value="" />
        </label>
    </div>
</div>

And add thisjavascript at the bottom of the form.

(function($){
    $('#privat-chk').change(function(){
        setval(this);
    });

    setval(document.getElementById('privat-chk'));

    function setval(el) {
        $('#jform_access').val('1');
        if(el.checked) {
            $('#jform_access').val('3');
        }
    }        
}(jQuery))

This is custom access level form element in form of checkbox. it is either 1 - public or 3 - special. Special means only article author amd administrators will be able to access it.

Работает на Cobalt