Ñïèñîê ôîðóìîâ Cake-PHP.ru Cake-PHP.ru
Ôîðóì ïðîãðàììèñòîâ CakePHP
(íà ñàéò)
 
 Watched TopicsWatched Topics   FAQFAQ   ÏîèñêÏîèñê   ÏîëüçîâàòåëèÏîëüçîâàòåëè   ÃðóïïûÃðóïïû   ÐåãèñòðàöèÿÐåãèñòðàöèÿ 
 ÏðîôèëüÏðîôèëü   Âîéòè è ïðîâåðèòü ëè÷íûå ñîîáùåíèÿÂîéòè è ïðîâåðèòü ëè÷íûå ñîîáùåíèÿ   ÂõîäÂõîä 

Ðåäàêòèðîâàíèå Ì, êîãäà ÷àñòü íåîáõîäèìûõ ïîëåé îòñóòñòâóåò?

 
Íà÷àòü íîâóþ òåìó   Îòâåòèòü íà òåìó    Ñïèñîê ôîðóìîâ Cake-PHP.ru -> Îáùèé
Ïðåäûäóùàÿ òåìà :: Ñëåäóþùàÿ òåìà  
Àâòîð Ñîîáùåíèå
TyurinP

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 20 Îêò 2008 13:36:01
Ñîîáùåíèÿ: 11
Îòêóäà: Kiev

ÑîîáùåíèåÄîáàâëåíî: 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 â ñêðûòîì ïîëå, íî ýòî æå íåâåðíûé ïîäõîä. Êàê èçáåæàòü ïðîâåðêè îòñóòñòâóþùèõ â ôîðìå ïîëåé?

Ñïàñèáî
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
michas

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 28 ßíâ 2008 11:28:31
Ñîîáùåíèÿ: 123

ÑîîáùåíèåÄîáàâëåíî: 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:36:01
Ñîîáùåíèÿ: 11
Îòêóäà: Kiev

ÑîîáùåíèåÄîáàâëåíî: 20 Îêò 2008 15:51:06    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

Ñïàñèáî michas

íî âîò âîïðîñ, åñëè ÿ ïîñòàâëþ äëÿ email 'on' => 'create'
òî íàïðèìåð ïðè ðåäàêòèðîâàíèè ïðîôèëÿ, ïîëüçîâàòåëü ñìîæåò óäàëèòü ñâîé óêàçàííûé ïðè ðåãèñòðàöèè email è íèêàêèõ ñîîáùåíèé îá îøèáêàõ íå ïîëó÷èò?
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
michas

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 28 ßíâ 2008 11:28:31
Ñîîáùåíèÿ: 123

ÑîîáùåíèåÄîáàâëåíî: 20 Îêò 2008 16:44:22    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

íó çàäàâàéòå òîãäà ïðàâèëà âàëèäàöèè èç êîíòðîëëåðà. äëÿ êàæäîãî ýêøèíà - ñâîé
_________________
Âñå ñàìîå èíòåðåñíîå â ðåàëüíîì âðåìåíè - xmpp:cakephp@conference.jabber.ru
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå Ïîñåòèòü ñàéò àâòîðà
TyurinP

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 20 Îêò 2008 13:36:01
Ñîîáùåíèÿ: 11
Îòêóäà: Kiev

ÑîîáùåíèåÄîáàâëåíî: 20 Îêò 2008 17:01:58    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

michas ïèñàë(à):
íó çàäàâàéòå òîãäà ïðàâèëà âàëèäàöèè èç êîíòðîëëåðà. äëÿ êàæäîãî ýêøèíà - ñâîé

äà êîíå÷íî! ýòî âàðèàíò, íî ÿ äóìàë, ÷òî åñòü åùå êàêîé-òî âûõîä èç òàêîé ñèòóàöèè
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
michas

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 28 ßíâ 2008 11:28:31
Ñîîáùåíèÿ: 123

ÑîîáùåíèåÄîáàâëåíî: 20 Îêò 2008 18:18:28    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

äóìàþ âðÿòëè åñòü äðóãîé âàðèàíò â âàøåì ñëó÷àå
_________________
Âñå ñàìîå èíòåðåñíîå â ðåàëüíîì âðåìåíè - xmpp:cakephp@conference.jabber.ru
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå Ïîñåòèòü ñàéò àâòîðà
michas

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 28 ßíâ 2008 11:28:31
Ñîîáùåíèÿ: 123

ÑîîáùåíèåÄîáàâëåíî: 21 Îêò 2008 10:24:02    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

ïî÷èòàë ìàíóàë, ïðè ñîñòàâëåíèè ïðàâèëà äëÿ âàëèäàöèè ïîëÿ åñòü ïàðàìåòð 'required' åñëè ïàðàìåòð óñòàíîâëåí â ïîëîæåíèå "true', òîãäà îíî îáÿçàòåëüíî âàëèäèðóåòñÿ åñëè 'false' òî âàëèäàöèÿ äîëæíà ïðîñèõîäèòü òîëüêî â òîì ñëó÷àå êîãäà ïîëå ïðèñóòñòâóåò â ìàññèâå data. ïîïðîáóéòå òàê ñäåëàòü
_________________
Âñå ñàìîå èíòåðåñíîå â ðåàëüíîì âðåìåíè - xmpp:cakephp@conference.jabber.ru
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå Ïîñåòèòü ñàéò àâòîðà
TyurinP

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 20 Îêò 2008 13:36:01
Ñîîáùåíèÿ: 11
Îòêóäà: Kiev

ÑîîáùåíèåÄîáàâëåíî: 21 Îêò 2008 15:19:14    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

Î! áîëüøîå ñïàñèáî, ïîïðîáóþ ýòî èìååíî òî, ÷òî íàäî
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
DeeperMD

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 08 Ôåâ 2008 15:04:11
Ñîîáùåíèÿ: 144
Îòêóäà: $Ìîëäîâà->Êèøèí¸â->Áóþêàíû()

ÑîîáùåíèåÄîáàâëåíî: 28 Îêò 2008 21:35:42    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

À åñëëè ïîéòè îò äðóãîãî... ïðîñòî ñäåëàòü unset òåì ñâîéñòâàì ìîäåëè êîòîðûå íå íóæíû â äàíûé ìîìåíò.
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
TyurinP

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 20 Îêò 2008 13:36:01
Ñîîáùåíèÿ: 11
Îòêóäà: Kiev

ÑîîáùåíèåÄîáàâëåíî: 29 Îêò 2008 16:30:13    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

DeeperMD ïèñàë(à):
À åñëëè ïîéòè îò äðóãîãî... ïðîñòî ñäåëàòü unset òåì ñâîéñòâàì ìîäåëè êîòîðûå íå íóæíû â äàíûé ìîìåíò.


Ïîõîæå íà òî, ÷òî ýòîò âàðèàíò ìíå ïîäõîäèò äàæå áîëüøå.
Ñïàñèáî!!!

ò.å. ÿ ìîãó íàïèñàòü
Êîä:

unset($this->User->validate['email']);

÷òîá îòìåíèòü âàëèäàöèþ email äëÿ User ???
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
DeeperMD

öèòèðîâàòü



Çàðåãèñòðèðîâàí: 08 Ôåâ 2008 15:04:11
Ñîîáùåíèÿ: 144
Îòêóäà: $Ìîëäîâà->Êèøèí¸â->Áóþêàíû()

ÑîîáùåíèåÄîáàâëåíî: 29 Îêò 2008 22:50:43    Çàãîëîâîê ñîîáùåíèÿ: Îòâåòèòü ñ öèòàòîé

ÿ íå ïðîáîâàë íî â ïðèíöèïå äîëæíî ïðîêàòèòü.. ýòî æå îáû÷íîå ñâîéñòâî îáû÷íîãî êëàññà..
Âåðíóòüñÿ ê íà÷àëó
Ïîñìîòðåòü ïðîôèëü Îòïðàâèòü ëè÷íîå ñîîáùåíèå
Èìÿ
Ñîîáùåíèå

Ñìàéëèêè
Very Happy Smile Sad Surprised
Shocked Confused Cool Laughing
Mad Razz Embarassed Crying or Very sad
Evil or Very Mad Twisted Evil Rolling Eyes Wink
Exclamation Question Idea Arrow
Äîïîëíèòåëüíûå ñìàéëèêè

 
Ïîêàçàòü ñîîáùåíèÿ:   
Íà÷àòü íîâóþ òåìó   Îòâåòèòü íà òåìó    Ñïèñîê ôîðóìîâ Cake-PHP.ru -> Îáùèé ×àñîâîé ïîÿñ: GMT + 3
Ñòðàíèöà 1 èç 1

 
Ïåðåéòè:  
Âû ìîæåòå íà÷èíàòü òåìû
Âû ìîæåòå îòâå÷àòü íà ñîîáùåíèÿ
Âû ìîæåòå ðåäàêòèðîâàòü ñâîè ñîîáùåíèÿ
Âû ìîæåòå óäàëÿòü ñâîè ñîîáùåíèÿ
Âû íå ìîæåòå ãîëîñîâàòü â îïðîñàõ


Powered by phpBB © 2001, 2005 phpBB Group
Ðóññêàÿ ïîääåðæêà phpBB

Ðåéòèíã@Mail.ru