Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Kohana] Validation i definiowanie alertów o błędzie
netvalue
post 21.04.2009, 16:18:49
Post #1





Grupa: Zarejestrowani
Postów: 199
Pomógł: 2
Dołączył: 9.06.2008

Ostrzeżenie: (0%)
-----


Hej,

Naprawdę denerwujące jest tworzenie dla każdego obiektu INPUT (który ma być walidowany) tablicy z opisami błędów jakie ewentualnie
wystąpiły podczas walidacji.

Przykładowy plik który otwieram metodą $post->errors('plik'):

plik.php
  1. <?php defined('SYSPATH') or die('No direct access allowed.');
  2.  
  3. $lang = array
  4. (
  5. 'input_email' => Array(
  6.  
  7.        'alpha' => 'Only alphabetic characters are allowed.',
  8.        'length' => 'The name must be between three and twenty letters.',
  9.        'required' => 'The number cannot be blank.',
  10.        'numeric' => 'Only numbers are allowed.',
  11.        'default' => 'Invalid Input.',
  12.    'email'=>' Email  is wrong',
  13.  
  14.  ),
  15.  
  16. 'name' => Array(
  17.  
  18.        'alpha' => 'Only alphabetic characters are allowed.',
  19.        'length' => 'The name must be between three and twenty letters.',
  20.        'required' => 'The number cannot be blank.',  
  21.        'default' => 'Invalid Input.',
  22.  
  23.  ),
  24. 'street' => Array(
  25.  
  26.        'alpha' => 'Only alphabetic characters are allowed.',
  27.        'length' => 'The name must be between three and twenty letters.',
  28.        'required' => 'The number cannot be blank.',  
  29.        'default' => 'Invalid Input.',
  30.  
  31.  )
  32. );
  33. ?>


Dla mnie to jest totalna porażka takie rozwiązanie a raczej powtarzanie siebie. Jest to metoda zalecana w oficjalnej dokumentacji Kohana.
Kiedyś we wcześniejszych wersjach fw, można było używać pliku validation.php i wszystko było ok. Na forum kohana nic nie znalazłem co
by mi pomogło.

Może ktoś z Was ma jakieś swoje rozwiązanie ?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 15.06.2024 - 13:14