Wednesday 15 July 2015

Yii validation compare against related model's Attribute when create new model -


When I agree to compare one of the properties of a newly created model against the respective model's properties I have been searching for some time and really do not find any useful information.

In my other models, while updating, this piece of code (in the model) is working: Compare public functionsDisendantCaseJb () {$ gyermek = $ This- & gt; Scion (1) - & gt; Search (); If ($ gyermek & lt; & gt; null) {If ($ gyermek-> KJZDB <$ this-> KJZDB) {$ this- & gt; AddError ('keszDb', Yii :: t ('validation', 'some error message')); }}} Public Function Rules () {Return Array (Array ('KZDB', 'compare WideCendantsJSDB');); }

But the same approach is no longer working, perhaps it is because it is now making the function. I have also tried to do this (in the model too):

  Compare public functionswizeryGuertamDBB () {$ szeriaGyartmany = SzeriaGyartmany :: model () - & gt; FindByPk ($ this-> szeriaGyartmanyId); If ($ the-> db> $ szeriaGyartmany- & gt; db) {$ this- & gt; Junk error ('db', Yii :: t ('validation', "error: max you can save $ szeriaGyartmany- & gt; db"); }} Public Function Rules () {Return Array (array ('db', 'compare paragraphiagyartam ddb');); }   

I hope this is something clear that what I want to achieve. Can anyone point me in the right direction? Thanks a lot!

BRC

Try to use the secure attribute for verification Gone

  Public function rules () {Return Array (array ('db', 'compare_theresia_greatmoneybb,' 'secure');); }    

No comments:

Post a Comment