public function rules() { return [ [['nac', 'ci', 'nombre', 'apellido', 'rif', 'telefono', 'correo'], 'string'], [['fecha'], 'safe'], *[['cedulabus'], 'string', 'length' => [7, 8]], [['id_usuario'], 'default', 'value' => null], [['id_usuario'], 'integer'], [['id_usuario'], 'exist', 'skipOnError' => true, 'targetClass' => Userbackend::className(), 'targetAttribute' => ['id_usuario' => 'id_usuario']], ['cedulabus', 'required'], [ 'tipo_persona','required'], ]; } otro ejemplo public function rules() { return [ [['nac', 'ci', 'nombre', 'apellido', 'rif', 'telefono', 'correo'], 'string'], [['fecha'], 'safe'], /*[['cedulabus'], 'string', 'length' => [7, 8],'message' => 'La cédula debe contener al menos 7 números'],*/ *['cedulabus', 'match', 'pattern' => '/^.{7,8}$/', 'message' => 'La cédula debe contener al menos 7 Números'], [['id_usuario'], 'default', 'value' => null], [['id_usuario'], 'integer'], [['id_usuario'], 'exist', 'skipOnError' => true, 'targetClass' => Userbackend::className(), 'targetAttribute' => ['id_usuario' => 'id_usuario']], ['cedulabus', 'required'], [ 'tipo_persona','required'], ]; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter