Cake-PHP.ru
Ôîðóì ïðîãðàììèñòîâ CakePHP
(íà ñàéò)
Watched Topics
FAQ
Ïîèñê
Ïîëüçîâàòåëè
Ãðóïïû
Ðåãèñòðàöèÿ
Ïðîôèëü
Âîéòè è ïðîâåðèòü ëè÷íûå ñîîáùåíèÿ
Âõîä
Ñïèñîê ôîðóìîâ Cake-PHP.ru
->
Îáùèé
Îòâåòèòü
Èìÿ
Òåìà
Ñîîáùåíèå
Ñìàéëèêè
Äîïîëíèòåëüíûå ñìàéëèêè
Öâåò øðèôòà:
Ïî óìîë÷àíèþ
Ò¸ìíî-êðàñíûé
Êðàñíûé
Îðàíæåâûé
Êîðè÷íåâûé
Ƹëòûé
Çåë¸íûé
Îëèâêîâûé
Ãîëóáîé
Ñèíèé
Ò¸ìíî-ñèíèé
Èíäèãî
Ôèîëåòîâûé
Áåëûé
׸ðíûé
Ðàçìåð øðèôòà:
Ðàçìåð øðèôòà
Î÷åíü ìàëåíüêèé
Ìàëåíüêèé
Îáû÷íûé
Áîëüøîé
Îãðîìíûé
Çàêðûòü òåãè
Íàñòðîéêè
HTML
ÂÛÊËÞ×ÅÍ
BBCode
ÂÊËÞ×ÅÍ
Ñìàéëèêè
ÂÊËÞ×ÅÍÛ
Îòêëþ÷èòü â ýòîì ñîîáùåíèè BBCode
Îòêëþ÷èòü â ýòîì ñîîáùåíèè ñìàéëèêè
Åñëè ó âàñ ïëîõîå çðåíèå èëè âû íå ìîæåòå ïðî÷åñòü ýòîò êîä ïî êàêîé-òî äðóãîé ïðè÷èíå, òî îáðàòèòåñü çà ïîìîùüþ ê
Àäìèíèñòðàòîðó
.
Êîä ïîäòâåðæäåíèÿ: *
Ââåäèòå êîä â òî÷íîñòè òàê, êàê âû åãî âèäèòå. Êîä ÿâëÿåòñÿ ðåãèñòðî-çàâèñèìûì, à ñèìâîë íóëÿ èìååò êîñóþ ëèíèþ âíóòðè öèôðû.
×àñîâîé ïîÿñ: GMT + 3
Ïåðåéòè:
Âûáåðèòå ôîðóì
CakePHP Ôîðóì
----------------
Îáùèé
Óñòàíîâêà è íàñòðîéêà
Òâîð÷åñòâî
Âîïðîñû è ïîæåëàíèÿ
Êîììåíòàðèè ê ãëàâàì ðóêîâîäñòâà ïî CakePHP 1.1
Îáçîð òåìû
Àâòîð
Ñîîáùåíèå
DeeperMD
Äîáàâëåíî: 29 Îêò 2008 22:50:43
Çàãîëîâîê ñîîáùåíèÿ:
ÿ íå ïðîáîâàë íî â ïðèíöèïå äîëæíî ïðîêàòèòü.. ýòî æå îáû÷íîå ñâîéñòâî îáû÷íîãî êëàññà..
TyurinP
Äîáàâëåíî: 29 Îêò 2008 16:30:13
Çàãîëîâîê ñîîáùåíèÿ:
DeeperMD ïèñàë(à):
À åñëëè ïîéòè îò äðóãîãî... ïðîñòî ñäåëàòü unset òåì ñâîéñòâàì ìîäåëè êîòîðûå íå íóæíû â äàíûé ìîìåíò.
Ïîõîæå íà òî, ÷òî ýòîò âàðèàíò ìíå ïîäõîäèò äàæå áîëüøå.
Ñïàñèáî!!!
ò.å. ÿ ìîãó íàïèñàòü
Êîä:
unset($this->User->validate['email']);
÷òîá îòìåíèòü âàëèäàöèþ
email
äëÿ
User
???
DeeperMD
Äîáàâëåíî: 28 Îêò 2008 21:35:42
Çàãîëîâîê ñîîáùåíèÿ:
À åñëëè ïîéòè îò äðóãîãî... ïðîñòî ñäåëàòü unset òåì ñâîéñòâàì ìîäåëè êîòîðûå íå íóæíû â äàíûé ìîìåíò.
TyurinP
Äîáàâëåíî: 21 Îêò 2008 15:19:14
Çàãîëîâîê ñîîáùåíèÿ:
Î! áîëüøîå ñïàñèáî, ïîïðîáóþ ýòî èìååíî òî, ÷òî íàäî
michas
Äîáàâëåíî: 21 Îêò 2008 10:24:02
Çàãîëîâîê ñîîáùåíèÿ:
ïî÷èòàë ìàíóàë, ïðè ñîñòàâëåíèè ïðàâèëà äëÿ âàëèäàöèè ïîëÿ åñòü ïàðàìåòð 'required' åñëè ïàðàìåòð óñòàíîâëåí â ïîëîæåíèå "true', òîãäà îíî îáÿçàòåëüíî âàëèäèðóåòñÿ åñëè 'false' òî âàëèäàöèÿ äîëæíà ïðîñèõîäèòü òîëüêî â òîì ñëó÷àå êîãäà ïîëå ïðèñóòñòâóåò â ìàññèâå data. ïîïðîáóéòå òàê ñäåëàòü
michas
Äîáàâëåíî: 20 Îêò 2008 18:18:28
Çàãîëîâîê ñîîáùåíèÿ:
äóìàþ âðÿòëè åñòü äðóãîé âàðèàíò â âàøåì ñëó÷àå
TyurinP
Äîáàâëåíî: 20 Îêò 2008 17:01:58
Çàãîëîâîê ñîîáùåíèÿ:
michas ïèñàë(à):
íó çàäàâàéòå òîãäà ïðàâèëà âàëèäàöèè èç êîíòðîëëåðà. äëÿ êàæäîãî ýêøèíà - ñâîé
äà êîíå÷íî! ýòî âàðèàíò, íî ÿ äóìàë, ÷òî åñòü åùå êàêîé-òî âûõîä èç òàêîé ñèòóàöèè
michas
Äîáàâëåíî: 20 Îêò 2008 16:44:22
Çàãîëîâîê ñîîáùåíèÿ:
íó çàäàâàéòå òîãäà ïðàâèëà âàëèäàöèè èç êîíòðîëëåðà. äëÿ êàæäîãî ýêøèíà - ñâîé
TyurinP
Äîáàâëåíî: 20 Îêò 2008 15:51:06
Çàãîëîâîê ñîîáùåíèÿ:
Ñïàñèáî
michas
íî âîò âîïðîñ, åñëè ÿ ïîñòàâëþ äëÿ
email
'on' => 'create'
òî íàïðèìåð ïðè ðåäàêòèðîâàíèè ïðîôèëÿ, ïîëüçîâàòåëü ñìîæåò óäàëèòü ñâîé óêàçàííûé ïðè ðåãèñòðàöèè email è íèêàêèõ ñîîáùåíèé îá îøèáêàõ íå ïîëó÷èò?
michas
Äîáàâëåíî: 20 Îêò 2008 15:30:47
Çàãîëîâîê ñîîáùåíèÿ:
Êîä:
var $validate = array(
'fieldName1' => array(
'rule' => 'ruleName', // or: array('ruleName', 'param1', 'param2' ...)
'required' => true,
'allowEmpty' => false,
'on' => 'create', // or: 'update'
'message' => 'Your Error Message'));
Öèòàòà:
The ‘on’ key can be set to either one of the following values: ‘update’ or ‘create’. This provides a mechanism that allows a certain rule to be applied either during the creation of a new record, or during update of a record.
If a rule has defined ‘on’ => ‘create’, the rule will only be enforced during the creation of a new record. Likewise, if it is defined as ‘on’ => ‘update’, it will only be enforced during the updating of a record.
The default value for ‘on’ is null. When ‘on’ is null, the rule will be enforced during both creation and update.
TyurinP
Äîáàâëåíî: 20 Îêò 2008 13:57:38
Çàãîëîâîê ñîîáùåíèÿ: Ðåäàêòèðîâàíèå Ì, êîãäà ÷àñòü íåîáõîäèìûõ ïîëåé îòñóòñòâóåò?
Äîáðûé äåíü!
Íåäàâíî îñâàèâàþ cakePHP, ñèñòåìà íðàâèòüñÿ íî âîçíèêàþ âîïðîñû, ìîæåò òå, ó êîãî îïûò ïîáîëüøå ïîäñêàæóò.
cakephp 1.2
èìååì ìîäåëü User c òàêîé âàëèäàöèåé
Êîä:
var $validate = array(
'username' => array(
'username1' => array(
'rule' => array('custom', '/[a-zA-Z0-9_]/'),
'required' => true,
'message' => 'Username cannot be empty'
),
'username2' => array(
'rule' => 'isUnique',
'message' => 'This username has already been taken.'
)
),
'email' => array(
'rule' => 'email',
'required' => true,
'message' => 'Please enter a valid email'
),
'password' => array(
'passwordSimilar' => array(
'rule' => 'checkPasswords',
'message' => 'Different password re entered.'
)
),
'password2' => array(
'long' => array(
'rule' => array('between', 5, 15),
'message' => 'Passwords must be between 5 and 15 characters long.'
)
)
);
ò.å. íåîáõîäèìûå ïîëÿ
username
è
email
äîïóñòè ÿ äåëàþ ôóíêöèþ ñìåíû ïàðîëÿ è ïîëÿ email ó ìåíÿ â ôîðìå íåò. Ïðè ïîïûòêå
Êîä:
$this->User->save($this->data);
ìíå âûäàåòñÿ îøèáêà, ÷òî ìîë íåò çíà÷åíèÿ email, óäîâëåòâîðÿþùåãî óñëîâèÿì. Ïîêà ÷òî âûâîæó email â ñêðûòîì ïîëå, íî ýòî æå íåâåðíûé ïîäõîä. Êàê èçáåæàòü ïðîâåðêè îòñóòñòâóþùèõ â ôîðìå ïîëåé?
Ñïàñèáî
Powered by phpBB © 2001, 2005 phpBB Group
Ðóññêàÿ ïîääåðæêà phpBB
Åñëè íè÷åãî èíòåðåñíîãî íå íàøëè, ìîæíî ðåêëàìó ïî÷èòàòü, à ðåêëàìèðóåòñÿ ó íàñ ñåãîäíÿ «».