title: yii2 validate related models
body: <p>We have 2 models:</p>
  
  <ul>
  <li>Order  </li>
  <li>OrderItems  </li>
  </ul>
  
  <p>So when saving the related OrderItems I need to check some attributes from the parent Order.  </p>
  
  <p>Order has attributes: "time_begin" and "time_end" and OrderItem has its own "time_begin" and "time_end". So the rule is that times of the OrderItem must be between times of the parent Order.</p>
  
  <p>For example, I have the following situation:</p>
  
  <ul>
  <li>user changes the "time_end" of the Order to the bigger value and changes the "time_end" of OrderItem to bigger value too</li>
  <li>try to save all the related data (Order and all its Items)</li>
  <li>Order validations pass successfully</li>
  <li>but when the OrderItem trying to validate its "time_end", it takes the old value of Order->time_end property and gives an validation error!!!</li>
  </ul>
  
  <p>Any solution???
  How to let OrderItem to know that Order has changed?</p>