2014-04-28 10 views
1

그냥 꽤 표준 사용자 편집 페이지를 만들려고합니다. '비밀번호'및 '재 비밀번호'는 숨기기 시작하지만 '비밀번호 수정'버튼을 클릭하여 '켜기'로 설정할 수 있습니다.UnlockField가 CakePHP에서 작동하지 않습니다

하지만 보안 구성 요소에서 "인증"블랙 홀 오류가 계속 발생합니다. the CakePHP book

, 방금 형태 전에, 바로 폼 내부 필드 후 필드 전에 시도보기 (이 함께 필드를 잠금 해제 시도하고 양식의 끝에 :

$this->Form->unlockField('User.password'); 
$this->Form->unlockField('User.re-password'); 

그러나 - 도움이되지 않습니다 내가 작업에 얻을 수있는 유일한 방법은 완전히 전체 동작 (이상하지 않는 것) 잠금을 해제이었다. 나는 필드를 사용하지 않는 경우, 그것을

$this->Security->unlockedActions = array('admin_edit'); 

을 작동하지 않지만 내장되어 있지 않은 "notEmpty"측면이 원인이되기 때문에 비활성화해야합니다. 해당 필드를 찾을 때 javascript 오류가 발생합니다.

보기/HTML :

<div id="edit-password-area" style="display:none;"> 
    <div class="form-group"> 
     <label>Password</label> 
     <?php echo $this->Form->input('User.password', array('class'=>'input-xxlarge form-control', 'value'=>'', 'disabled'=>'disabled')); ?> 
     <p class="note">Must be at least 8 characters in length.</p> 
    </div> 
    <div class="form-group"> 
     <label>Verify Password</label> 
     <?php echo $this->Form->input('User.re_password', array('type'=>'password', 'class'=>'input-xxlarge form-control', 'value'=>'', 'disabled'=>'disabled')); ?> 
     <p class="note">Must exactly match the "Password".</p> 
    </div> 
</div> 

<div id="edit-password-button-area"> 
    <a href="javascript:showPasswordArea();">Edit Password</a> 
</div> 

<div id="dont-edit-password-button-area" style="display:none;"> 
    <a href="javascript:hidePasswordArea();">Don't Edit Password</a> 
</div> 

자바 스크립트 :

<script> 
function showPasswordArea() { 
    $('#edit-password-area').show(); 
    $('#edit-password-area input').removeAttr('disabled'); 
    $('#dont-edit-password-button-area').show(); 
    $('#edit-password-button-area').hide(); 
    $('#UserPassword').focus(); 
} 
function hidePasswordArea() { 
    $('#edit-password-area').hide(); 
    $('#edit-password-area input').prop('disabled', 'disabled'); 
    $('#dont-edit-password-button-area').hide(); 
    $('#edit-password-button-area').show(); 
} 
</script> 

답변

0

이 구문을보십시오은 :

$this->Security->unlockedFields = array('yourfield'); 
+0

나는 것을 시도, 그것은 작동하지 않습니다. : / – Dave

관련 문제