PyroCMS 1.3.1을 사용하여 포함 된 연락처 모델의 복사 - 붙여 넣기 버전을 만들었지 만 약간의 개조가있는 모델을 만들었습니다. 모든 입력란이 올바르게 입력되면 모든 것이 예상대로 작동합니다. 입력란을 생략하거나 잘못 입력하면 양식이 예상대로 제출되지 않습니다.PyroCMS에서 양식 유효성 검사 오류가 출력되지 않았습니다.
그러나 출력 할 양식 유효성 검사 메시지를 얻지 못하고 이것이 나를 미치게 만듭니다. 나는 아주 기본적인 것을 놓쳤을 것입니다. 누군가가 그것을 지적 할 수 있다면 감사 할 것입니다.
보기 파일 (form.php)이
<?php if (validation_errors()): ?>
<div class="error-box">
<?php echo validation_errors(); ?>
</div>
<?php elseif (isset($messages['error'])): ?>
<div class="error-box">
<p><?php echo $messages['error']; ?></p>
</div>
<?php endif; ?>
컨트롤러 (plugin.php이) 그래서 내가 CodeIgniters 언어를 사용자 정의 작업을하는 동안 밝혀이
class Plugin_mycustommodule extends Plugin {
private $rules = array(
array(
'field' => 'firstname',
'label' => 'lang:mycustommodule_firstname_label',
'rules' => 'required|trim|max_length[80]'
),
/* ... snip ... */
array(
'field' => 'license',
'label' => 'lang:mycustommodule_license_label',
'rules' => 'required'
)
);
public function __construct()
{
$this->lang->load('mycustommodule');
}
function form()
{
$this->load->library('form_validation');
$this->load->helper('form');
$this->form_validation->set_rules($this->rules);
// If the user has provided valid information
if ($this->form_validation->run())
{
/* ... Custom processing here ... */
// The try to send the email
if ($this->_send_email())
{
$message = $this->attribute('confirmation', lang('mycustommodule_sent_text'));
// Store this session to limit useage
$this->session->set_flashdata('success', $message);
redirect(current_url());
}
else
{
$message = $this->attribute('error', lang('mycustommodule_error_message'));
$data['messages']['error'] = $message;
}
}
// Set the values for the form inputs
foreach ($this->rules as $rule)
{
$form_values->{$rule['field']} = set_value($rule['field']);
}
$data['form_values'] = $form_values;
return $this->module_view('mycustommodule', 'form', $data, TRUE);
}