양식을 제출할 때 비활성화 된 양식 필드가 요청에 제출되지 않습니다.젠드 프레임 워크 : isValid()는 비활성화 된 양식 필드에서 값을 지 웁니다!
양식에 사용할 수없는 양식 필드가있는 경우 Zend_Form::isValid()
으로 작업하면 다소 실망 스럽습니다.
$form->populate($originalData);
$form->my_text_field->disabled = 'disabled';
if (!$form->isValid($_POST)) {
//form is not valid
//since my_text_field is disabled, it doesn't get submitted in the request
//isValid() will clear the disabled field value, so now we have to re-populate the field
$form->my_text_field->value($originalData['my_text_field']);
$this->view->form = $form;
return;
}
// if the form is valid, and we call $form->getValues() to save the data, our disabled field value has been cleared!
양식을 다시 채우지 않고 중복 된 코드 줄을 만들지 않고도이 문제에 접근하는 가장 좋은 방법은 무엇입니까?
실제로 젠드 양식은 아닙니다. HTML 스펙에 따르면 disabled 요소는 제출되지 않지만 readonly 요소는 수행합니다 (아래 @robertbasic의 제안을 설명 함). –