tanakahisateru / pinoco

Web site development framework using PHP and (mainly) PHPTAL
http://tanakahisateru.github.io/pinoco/
Other
43 stars 10 forks source link

Pinoco_Validator's empty result for form initial state #46

Closed tanakahisateru closed 12 years ago

tanakahisateru commented 12 years ago

We always should create Pinoco_Validator's result formatted object by alternative way to share form view with initial-page and error-back-page.

<?php
if(!empty($_POST)) {
    $validator = new Pinoco_Validator($_POST);
    $validator->check(...)->is(...);
    $form = $validator->result;
}
else {
    $form = Pinoco_Validator::emptyResult(); // or ::emptyResult($defaults);
}

The $form value would be used as:

<input type="text" name="name" value="${form/foo/value}" />
<span class="error" tal:condition="form/foo/invalid">${form/foo/message}</span>

The empty result should be responsible for any names. I don't want to code list of field names.

tanakahisateru commented 12 years ago

Finished.