연락처의 ID가 포함 된 링크를 클릭 할 때마다 contact_status_id
필드의 연락처 테이블에서 상태 번호를 토글 링합니다. 페이지에 오류는 표시되지 않지만 조치로 번호가 변경되지는 않습니다. 아직 구현 된 유효성 검사가 없습니다.CakePHP, 편집 작업에서 문제를 발견 할 수 없음
아마도 신선한 눈이 문제를 일으킬 수 있습니까?
function inbox_toggle_number_status($id=null)
{
//Call from the inbox when the number is clicked and status toggled.
$this->User->Contact->id = $id;
if (!empty($id))
{
$current_status = $this->User->Contact->find('first', array('conditions' => array('id' => $id)));
if ($current_status['Contact']['contact_status_id'] == '1'):
$this->User->Contact->saveField('contact_status_id', '2');
exit();
elseif ($current_status['Contact']['contact_status_id'] == '2'):
$this->User->Contact->saveField('contact_status_id', '3');
exit();
elseif ($current_status['Contact']['contact_status_id'] == '3'):
$this->User->Contact->saveField('contact_status_id', '2');
exit();
else:
exit();
endif;
}
}
하나의 문제가 보이고 코드가 제대로 들여 쓰기가 어렵고 한 줄에 여러 개의 명령문이있어 읽기가 어려워 문제를 발견하기 어렵습니다. , 그리고 유지하기가 어렵다. 따라서 이것이 비즈니스의 첫 번째 주문이어야하며 코드를 읽을 수있게하십시오. –
맞아, 나는 조금 정돈했다. – ondrobaco