I would need some help implementing an optional model in my view. Basically, I have a modelsLocks that is required in the Update action, but not the Create action.
I create it properly in the Update action and my view works just fine, but in my Create, it doesn’t like
if( !$model->isNewRecord && !empty($modelsLocks) ){
if( $modelsLocks->UserId != $('#CurUsr').val() ){
alert("This booking is currently locked by another user and connot be edit at this time.");
}
}
Complaining that ‘Undefined variable: modelsLocks’
It seems to process the if( $modelsLocks->UserId != $(’#CurUsr’).val() ){ line even though it is a NewRecord … so obviously it will err, but how can I get around this?